Remove Hour minute second (Time) from DateTime in SQL Server

Last Reply one month ago By dharmendr

Posted one month ago

Hi Developers.

The field DATETIME in the database has the following format:

2019-02-20 21:34:25.490

I would like to remove the time from the date and return the date like this:

2019-02-20

how can i done this using sql server, if anyone knows kinldy help me.

Posted one month ago

Hi paulrajmca,

Check this example.

SQL

-- In SQL Server 2005 and below.
SELECT CONVERT(VARCHAR(10), GETDATE(), 120)
-- In SQL Server 2008 and Above.
SELECT CONVERT(DATE, GETDATE()) 

Output

2019-06-20