MSSQL: Get only the Date part from a DATETIME value
Here is something that I constantly have to use, and always have a hard time finding. From what I understand, this is the fastest way in TSQL (2005) to strip the time from a DATETIME value and return the date with a 00:00:00 timestamp.
CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)
It'll return a value such as '2009-03-18 00:00:00.000'.
Written By: mycodeshare on March 18, 2009 at 15:18
Submit a comment, suggestion, or additional information about this snippet
If you login or register,
you'll be able to post a comment or provide feedback about this snippet.