Login     Register

        Contact Us     Search

XLeratorDB/financial Documentation

SQL Server number-of-months between two dates


NUMMONTHS

Updated: 18 September 2014

Use the scalar function NUMMONTHS to return the number of months between 2 dates.
Syntax
SELECT [wct].[NUMMONTHS](
  <@StartDate, datetime,>
 ,<@EndDate, datetime,>)
Arguments
@StartDate
the start date. @StartDate is an expression that returns a datetime or smalldatetime value, or a character string in date format. 
@EndDate
the end date. @EndDate 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.
Months
-----------
1

 

See Also

 



Copyright 2008-2024 Westclintech LLC         Privacy Policy        Terms of Service