EOMONTH
Updated 2023-10-06 23:51:45.767000
Syntax
SELECT [westclintech].[wct].[EOMONTH] (
<@Start_date, datetime,>
,<@Months, int,>)
Description
Use the scalar function 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.
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 start date. @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.
Examples
SELECT wct.EOMONTH('2/15/2008', 0);
Here is the result set.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"2008-02-29 00:00:00.000"}]}