SELECT GETDATE()
Returns: 2008-09-22 15:24:13.790
I want that date part without the time part: 2008-09-22 00:00:00.000
How can I get that?
SELECT GETDATE()
Returns: 2008-09-22 15:24:13.790
I want that date part without the time part: 2008-09-22 00:00:00.000
How can I get that?
This was missing in all answers, may not be the most efficient but very easy to write and understand, no style needed, no complex date functions.
For return in date format
The above code will work in sql server 2010
It will return like 12/12/2013
For SQL Server 2012 use the below code
Okay, Though I'm bit late :), Here is the another solution.
Result
And if you are using SQL Server 2012 and higher then you can use
FORMAT()
function like this -Simply you can do this way:
Outputs as:
Or simply do like this:
Result: