Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time Range

Status
Not open for further replies.

gsavitha

MIS
Jan 28, 2011
14
GB

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
 
Code:
DECLARE @Yesterday datetime
SET @Yesterday = DATEADD(hh, 1, DATEADD(dd, DATEDIFF(dd, 0, GETDATE())-1, 0))

....
    cst.DateCreated >= @Yesterday
AND cs.DateCreated  <= DATEADD(hh, 24, @Yesterday)

Borislav Borissov
VFP9 SP2, SQL Server 2000,2005 & 2008.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top