GETDATE() function in SQL server

Che picture Che · Oct 26, 2017 · Viewed 12k times · Source

When running the SQL query:

select GETDATE()

I get the below output:

2017-10-26 12:48:41.273

It displays the date and the time. But I want the output as

2017-10-26 00:00:00

How to get such a date format?

Answer

Yogesh Sharma picture Yogesh Sharma · Oct 26, 2017

Try below :

SELECT CONVERT(DATETIME,CONVERT(VARCHAR(12),GETDATE(),112))

Result :

2017-10-26 00:00:00.000