How to get date only from datetime in T-SQL

Michael Roma on Nov 25, 2012

The following code snippets are examples of how to return the date only part from a datetime data type.

– all versions of SQL
select cast(convert(varchar(10),getdate(),121) as datetime)

– can be used on SQL 2008 and later
select cast(cast(getdate() as date) as datetime)