Answers for "How to return only the Date from a SQL Server DateTime datatype"

SQL
0

How to return only the Date from a SQL Server DateTime datatype

SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, @your_date))
for example

SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))
gives me

2008-09-22 00:00:00.000
Pros:

No varchar<->datetime conversions required
No need to think about locale
Posted by: Guest on February-05-2022

Code answers related to "How to return only the Date from a SQL Server DateTime datatype"

Code answers related to "SQL"

Browse Popular Code Answers by Language