SQL tip
May 22nd, 2008 by whit3kr0w
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.
Posted in Programming
Geekie.net RSS feed