EOMONTH
Updated: 5 August 2010
Use EOMONTH to calculate the date for the last day of the month that is the indicated number of months before or after the start date. Use EOMONTH to calculate maturity dates or due dates that fall on the last day of the month.
Syntax
SELECT [westclintech].[wct].[EOMONTH] (
<@Start_date, datetime,>
,<@Months, int,>)
Arguments
@Start_date
The date the number of months is added to or subtracted from. @Start_date is an expression that returns a datetime or smalldatetime value, or a character string in date format.
@Months
an integer added to the @Start_date representing the number of months before or after the startdate. @Months is an expression of type int or of a type that can be implicitly converted to int.
Return Type
datetime
Remarks
· To select the last day of the month of the @Start_date, set @Months to zero
· To select the last day of a month after @Start_date, make sure @Months is greater than zero
· To select the last day of a month before @Start_date, make sure @Months is less than zero
Example
SELECT wct.EOMONTH('2/15/2008'
,0)
Here is the result set
-----------------------
2008-02-29 00:00:00.000