[HowTo] Remove Time from date in SQL

--The correct way (new since Sql Server 2008):
cast(getdate() As Date)

--The correct way (old):
dateadd(dd, datediff(dd,0, getDate()), 0) 

--This is older now, but it's still worth knowing because it can also easily adapt for other time points, like the first moment of the month, minute, hour, or year.

--The fast way:
cast(floor(cast(getdate() as float)) as datetime)

--The wrong way:
cast(convert(char(11), getdate(), 113) as datetime)

Leave a Reply