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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 need help with SQL query

Author  Topic 

nev
Starting Member

2 Posts

Posted - 2006-02-28 : 11:17:53
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 ASC

ANY 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..

SELECT
vw_DALReport.IncidentIdentifier, vw_DALReport.ReportedByDateTime, vw_DALReport.
FROM
(database)
WHERE
vw_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 BY
vw_Report.ReportedByDateTime ASC
Go to Top of Page

nev
Starting Member

2 Posts

Posted - 2006-02-28 : 12:56:25
RickD,
Absolutely great; worked!
Go to Top of Page
   

- Advertisement -