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.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}