EOMONTH (TSQL Function)
Returns the last day of the month of the specified date. An optional month offset can be added to the date argument.
Syntax
EOMONTH ( date [, months_offset] )
Arguments
- date
- is a date expression of type
date
ordatetime
. - months_offset
- optional number of months to add to date, of type
int
. Default is 0.
Return Types
Returns same type as date argument.
Examples
DECLARE @d DATETIME = '2015-02-10';
PRINT EOMONTH(@d, 1);
PRINT EOMONTH(@d);
PRINT EOMONTH(@d, -1);
The result is:
2015-03-31 00:00:00
2015-02-28 00:00:00
2015-01-31 00:00:00