SQL tip
May 22, 2008
Quick SQL tip that I find useful. If you want just the date part of a datetime value, the following neat expression yields it:
SELECT DATEADD(d, 0, DATEDIFF(d, 0, datetime_column))
This is useful for comparing dates. Alternative approaches include casting to string, and comparing the date parts (day, month, year) separately. The context determines which is most appropriate.
Gently provided by SK.