Reputation: 26517
i have a table in SQL Server 2008 which its name is Table1. Table1 has a column named CreateDate which its data type is datetime. Now, I wanna to get records that their createDate field values are more than for instance 1 hour.
Upvotes: 0
Views: 630
Reputation: 8981
This will get records that are older than one hour:
select * from Table1 where createDate < dateadd(hh, -1, getdate())
Upvotes: 0
Reputation: 754220
In SQL Server 2008, you should use the built-in TIME
datetype as much as possible.
If you have a DATETIME column, you can easily convert it to just TIME by using:
SELECT CAST(CreateDate AS TIME) FROM Table1
That should return just the TIME part of the DATETIME column.
Marc
Upvotes: 3
Reputation: 11397
try with some datetime functions ,like DATEADD functions
e.g : select dateadd(hh,-1,GETDATE())
Upvotes: 1