Primary Key (PK)

Technical Article

RE: how to use time functions in sql server?

  • Reply

ok try something like this: create table t(d datetime) insert into t values('2002-01-01 14:15:02') insert into t values('2002-01-01 15:15:02') select * from t where abs(datediff(mi,cast('1900-01-01 '+substring(convert(char(19),d,120),12,19) as datetime), cast('1900-01-01 '+substring(convert(char(19),getdate(),120),12,19) as datetime))) <=30 Gregory Larsen, DBA If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

You rated this post out of 5. Change rating

2003-06-05

Technical Article

RE: Previous date's value

  • Reply

Just a thought from a rattled brain but... If you dont need to see the previous days balance prior to doing an insert or update, then why not just throw a trigger on the table that gets the highest value from the previous days balance, and updates the column for you during an insertion or […]

You rated this post out of 5. Change rating

2003-06-05

1 reads

Technical Article

RE: Previous date's value

  • Reply

Anbu. I frequently have to do this type of query. What i do is to create a temp table with an identity column. Add required rows ordering by key columns and date. Do Left join to self on key columns and tab1.id - 1 = tab2.id( retrieving previous day ) usually quite fast Anzio

You rated this post out of 5. Change rating

2003-06-05

2 reads

Blogs

Small Data SF 2024

By

I can’t remember how I heard about Small Data SF 2024, but it caught...

A New Word: Moledro

By

moledro – n. a feeling of resonant connection with an author or artist you’ll...

Snowflake + Azure blob

By

Let’s go back to data platforms today and I want to talk about a...

Read the latest Blogs

Forums

7 sept, scheduled book

By philip.scott

Comments posted to this topic are about the item 7 sept, scheduled book

7 sept, schedlued article

By philip.scott

Comments posted to this topic are about the item 7 sept, schedlued article

6 sept, published book

By philip.scott

Comments posted to this topic are about the item 6 sept, published book

Visit the forum

Question of the Day

Azure Data Lake Storage Gen 2

Azure Data Lake Storage Gen 2 is built on ...?

See possible answers