EOMONTH#
Returns the last day of the month that contains the specified date, with an optional offset.
Syntax#
EOMONTH ( start_date [, month_to_add ] )
Arguments#
start_date
Date expression specifying the date for which to return the last day of the month.
month_to_add
Optional integer expression specifying the number of months to add to _start*date*.
If this argument is specified, then EOMONTH adds the specified number of months to _start*date*, and then returns the last day of the month for the resulting date. If this addition overflows the valid range of dates, then an error is raised.
Return types#
date
Example#
DECLARE @date DATETIME = GETDATE();
SELECT EOMONTH ( @date ) AS 'This Month';
SELECT EOMONTH ( @date, 1 ) AS 'Next Month';
SELECT EOMONTH ( @date, -1 ) AS 'Last Month';