Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hello, I need some help with a query. I am trying capture some data between yesterday @6am through today at 6am. I do not want to use today's date (2006/2/28 06:00:00) as I would like to run this report daily. So somehow I need to grab the system date -1 @ 6am through system date (today) @6am.So far here is what I have (which of course is wrong):SELECT vw_DALReport.IncidentIdentifier, vw_DALReport.ReportedByDateTime, vw_DALReport.FROM (database) WHERE vw_report.ReportedByDateTime >= "2006/2/26 05:59:59AM" AND vw_Report.ReportedByDateTime < "2006/2/27 06:00:00AM" ORDER BY vw_Report.ReportedByDateTime ASCANY assistance would be helpful. Thanks so much!
RickD
Slow But Sure Yak Herding Master
3608 Posts
Posted - 2006-02-28 : 11:27:59
Something like..
SELECTvw_DALReport.IncidentIdentifier, vw_DALReport.ReportedByDateTime, vw_DALReport.FROM(database) WHEREvw_report.ReportedByDateTime >= dateadd(hh,6,dateadd(dd,datediff(dd,0,getdate()),-1)) AND vw_Report.ReportedByDateTime < dateadd(hh,6,dateadd(dd,datediff(dd,0,getdate()),0)) ORDER BYvw_Report.ReportedByDateTime ASC