Thursday, May 1, 2008

SQL Server Date-Only from DATETIME

SQL Server Date-Only from DATETIME

SELECT CONVERT(DATETIME, FLOOR(CONVERT(FLOAT, GETDATE())))
or
SELECT CONVERT(DATETIME, CONVERT(INT, GETDATE()))

On a slightly related note, KB article 327080 describes how ADO randomly rounds SQL Server milliseconds into seconds.

No comments: