Not logged in - Login

Drop time portion of date/time in SQL

The following illustrates a few ways to trim the time portion from a date/time field. Source: http://www.sqlusa.com/bestpractices/date-without-time/

select convert(datetime, convert(varchar, getdate(), 101))

-- Datetime - get date without time 
SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))
SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, CURRENT_TIMESTAMP))
-- 2012-03-15 00:00:00.000
------------

-- SQL Server 2008 / 2012 & on
SELECT CONVERT(DATE, CURRENT_TIMESTAMP)
-- 2012-03-15

------------
-- String date only conversion - without time
SELECT CONVERT(char(10), getdate(),111)