EOMONTH (Transact-SQL)
Returns the last day of the month that contains the specified date, with an optional offset.
A. EOMONTH with explicit datetime type
DECLARE @date DATETIME SET @date = '12/1/2011' SELECT EOMONTH ( @date ) AS Result GO
Here is the result set.
Result ------------ 2011-12-31 (1 row(s) affected)
B. EOMONTH with string parameter and implicit conversion
DECLARE @date VARCHAR(255) SET @date = '12/1/2011' SELECT EOMONTH ( @date ) AS Result GO
Here is the result set.
Result ------------ 2011-12-31 (1 row(s) affected)
C. EOMONTH with and without the month_to_add parameter
DECLARE @date DATETIME SET @date = GETDATE() SELECT EOMONTH ( @date ) AS 'This Month' SELECT EOMONTH ( @date, 1 ) AS 'Next Month' SELECT EOMONTH ( @date, -1 ) AS 'Last Month' GO
Here is the result set.
This Month ----------------------- 2011-12-31 (1 row(s) affected) Next Month ----------------------- 2012-01-31 (1 row(s) affected) Last Month ----------------------- 2011-11-30 (1 row(s) affected)

