Monday, October 6, 2008

Efficiently Rounding a SQL Server datetime

Truncates hours, minutes and seconds without messy string manipulation:

CAST(FLOOR(CAST(GETDATE() AS DECIMAL(8,2))) AS datetime)