Some date functions
Months: SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) - 1, 0) -- First day of previous month SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), -1) -- Last Day of previous month SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0) -- First day of this month SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) + 1, -1) -- Last day of this month SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) + 1, 0) -- First day of next month SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) + 2, -1) -- Last day of next month Quarters: SELECT DATEADD(QUARTER, DATEDIFF(QUARTER, 0, GETDATE()) -1, 0) -- First day of previous quarter SELECT DATEADD(QUARTER, DATEDIFF(QUARTER, 0, GETDATE()), -1) -- Last day of previous quarter SELECT DATEADD(QUARTER, DATEDIFF(QUARTER, 0, GETDATE()), 0) -- First day of this quarter SELECT DATEADD(QUARTER, DATEDIFF(QUARTER, 0, GETDATE()) + 1, -1) -- Last day of this quarter SELECT DATEADD(QUARTER, DATEDIFF(QUARTER, 0, GETDATE()) + 1, 0) -- First day of next q...