Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Time Range

Author  Topic 

satheesh
Posting Yak Master

152 Posts

Posted - 2011-07-05 : 07:25:07
Dear All,

I need to reterview data between the time range ie.Yesterday 1 Am to today 1 Am record (24hrs)

The below query pulls the data between (2011-07-04 00:00:00.000 to
2011-07-04 23:59:59.999)

cst.DateCreated >=DATEADD(dd,DATEDIFF(dd,0,GETDATE())-1,0)
AND cs.DateCreated <DATEADD(dd,DATEDIFF(dd,0,GETDATE()),0)

But i need data from (2011-07-04 01:00:00.000 to
2011-07-05 00:59:59.999).How to amend that query.Any Help would be highly appreciated.

Regards,
SG

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-07-05 : 07:38:02
WHERE DateCreated >= DATEADD(DAY, DATEDIFF(DAY, 1, GETDATE()), '01:00:00')
AND DateCreated < DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), '01:00:00')



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -