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.
+1
A:
try with some datetime functions ,like DATEADD functions
e.g : select dateadd(hh,-1,GETDATE())
anishmarokey
2009-09-26 13:46:44
+3
A:
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
marc_s
2009-09-26 14:05:47
A:
This will get records that are older than one hour:
select * from Table1 where createDate < dateadd(hh, -1, getdate())
Michael Valenty
2009-09-26 15:20:41