Tuesday, December 2, 2008

sql: get just the hour from a datetime

SELECT DATEADD(hh, 13, DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE())))

probably a fancier way to keep the hour information, but you can just in an hour variable there to add it back in.

replace getdate() with your date field

No comments: