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
 Selecting records from the last 10 hours

Author  Topic 

wildcatzphreak
Starting Member

2 Posts

Posted - 2009-09-24 : 17:54:15
Hey everyone. I apologize for the stupid question but I am new to SQL. I need a query that will pull results from the last 10 hours. This is something that I need the date/time to be populated automatically based on the machine's time, and not entered manually every time by the operator when the query is run.

So essentially something that says show results from current time - 10 hours to current time. NOT something that says show results from 12:00PM to 10:00PM.

It's sql server 2000.

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-09-24 : 17:58:32
SELECT * FROM myTable WHERE dateCol >= DateAdd(hour, -10, getdate())
Go to Top of Page

wildcatzphreak
Starting Member

2 Posts

Posted - 2009-09-24 : 18:05:22
Thanks a lot, much appreciated.
Go to Top of Page
   

- Advertisement -