Thursday, 24 August 2006

TSQL : Negate Time from DateTime column

update! doesn't incur an implicit conversion :
SELECT DATEADD(dd, DATEDIFF(dd, '1900-01-01', GETDATE()),'1900-01-01')

update! more efficient :
SELECT DATEADD(dd, DATEDIFF(dd,0,GETDATE()), 0)

original version :
SELECT CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)

No comments: