Logo

EDATE

Updated 2023-10-06 23:52:43.283000

Syntax

SELECT [westclintech].[wct].[EDATE] (
   <@Start_date, datetime,>
 ,<@Months, int,>)

Description

Use the scalar function EDATE to calculate the date that is the indicated number of months before or after a specified date (the start date). Use EDATE to calculate maturity dates or due dates that fall on the same day of the month as the date of issue.

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

Use -@Months to calculate a date prior to the @Start_Date.

Examples

SELECT wct.EDATE('8/31/2008', 6);

Here is the result set.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"2009-02-28 00:00:00.000"}]}
SELECT wct.EDATE('8/31/2008', -6);

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"}]}
SELECT wct.EDATE('4/30/2008', 1);

Here is the result set.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"2008-05-30 00:00:00.000"}]}
SELECT wct.EDATE('5/30/2008', -1);

Here is the result set.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"2008-04-30 00:00:00.000"}]}
SELECT wct.EDATE('5/31/2008', -1);

Here is the result set.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"2008-04-30 00:00:00.000"}]}