12 April 2011

How to set a date to the first / last day in TSQL

To set a date to the first / last day in TSQL:

First day:
SELECT DATEADD(mm, DATEDIFF(mm, 0, GETDATE()) + 1, 0)
Last Day :
SELECT DATEADD(dd, -1, DATEADD(mm, DATEDIFF(mm, 0, GETDATE()) + 1, 0))

No comments: