NUMMONTHS
Updated 2023-10-06 23:59:49.753000
Syntax
SELECT [westclintech].[wct].[NUMMONTHS](
<@StartDate, datetime,>
,<@EndDate, datetime,>)
Description
Use the scalar function NUMMONTHS to return the number of months between 2 dates.
Arguments
@EndDate
the end date. @EndDate is an expression that returns a datetime or smalldatetime value, or a character string in date format.
@StartDate
the start date. @StartDate is an expression that returns a datetime or smalldatetime value, or a character string in date format.
Return Type
int
Remarks
If @StartDate is NULL then @StartDate = GETDATE().
If @EndDate is NULL then @EndDate = GETDATE().
For calculation purposes all dates are treated as if they are the last day of the month.
Examples
SELECT wct.NUMMONTHS('2014-09-18', '2014-10-01') as [Months];
This produces the following result.
{"columns":[{"field":"Months","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"Months":"1"}]}
See Also
DAYSINMONTH - Number of days in the month of the specified date
DAYSINYEAR - Number of days in the year of the specified date