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 2005 Forums
 Transact-SQL (2005)
 Query Help

Author  Topic 

JeffS23
Posting Yak Master

212 Posts

Posted - 2007-12-29 : 01:03:34
I have a table which has a datetime field, which is auto populated by MSSQLs GETNOW function.

I would like a query that returns results with dates 6 hours old or less

SELECT *
From Story
WHERE datetime LTE 6 hours ago.

Can anyone offer help?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-12-29 : 01:09:33
GETNOW ? you mean getdate()

where [datetime] <= dateadd(hour, -6, getdate())



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -