How to get date only from datetime in T-SQL

Posted on November 25, 2012 by Michael Roma

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)
comments powered by Disqus