Eonmonth is an date function and returns the last day of the month that contains the specified date, with an optional offset.
EOMONTH Syntax:
EOMONTH ( date_expression [, add_month ] )
EOMONTH Example:
DECLARE @lastday DATETIME = '02/22/2014';
SELECT EOMONTH ( @lastday ) AS Result;
Result |
---|
2014-02-28 |
SELECT EOMONTH ( GETDATE() ) as 'This_Month',
EOMONTH ( GETDATE(), 1 ) as 'Next_Month',
EOMONTH ( GETDATE(), -1 ) as 'Last_Month';
This_Month | Next_Month | Last_Month |
---|---|---|
2014-02-28 | 2014-03-31 | 2014-01-31 |