DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Get The First And Last Day Of The Current Month T-SQL

03.10.2006
| 578 views |
  • submit to reddit
        // Get the first and last day of the current month T-SQL

declare @date datetime
set @date = getdate()

--get first day of month 
select dateadd(m, datediff(m, 0, @date), 0)

--get last day of month 
select dateadd(m, datediff(m, 0, dateadd(m, 1, @date)), -1)