Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Remove Time From A SQL Date

DZone's Guide to

Remove Time From A SQL Date

· ·
Free Resource
Convert a SQL date time into a date, aka, remove time from a SQL date


-- fast way that relies on the internal data structure
SELECT CAST( FLOOR( CAST( GETDATE() AS FLOAT ) ) AS DATETIME ) AS date_only

-- slower way that does not rely on internal data structure
SELECT CONVERT( DATETIME, CONVERT( NCHAR(10), GETDATE(), 126 ) ) AS date_only
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}