How to Get the Date of a DateTime in SQL Server

Pretty simple really. Try this SQL:

SELECT CONVERT(nvarchar(20), GetDate(), 101);

or

SELECT CONVERT(nvarchar(20), CAST(‘2008-04-04 16:07:07.920’ AS DateTime), 101);

If you need to use it in a comparison you can easily do something like

WHERE CONVERT(nvarchar(20), MyDateColumn, 101) BETWEEN @DateFrom AND @DateTo

Enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *