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: https://weblogs.sqlteam.com/mladenp/2005/08/01/7421/
Viewed 6889 times