Like somuch.com on Facebook Share somuch.com on Facebook somuch.com on Twitter Reddit LinkedIn Pinterest
Newest Tips & Tricks...

Home :: Tips & Tricks :: Microsoft SQL Server

How to get just date or just time from a datetime value

-- just date:
SELECT DATEADD(d, DATEDIFF(d, 0, GetDate()), 0)

-- just time:
SELECT DATEADD(d, -DATEDIFF(d, 0, GetDate()), GetDate())

Source: http://weblogs.sqlteam.com/mladenp/archive/2005/08/01/7421.aspx

Recommended Links...