Calculate the Number of Months Since a Given Date
To calculate the number of full months since a given date, you use the Temporal Months Since function. Note that this function will return a number attribute that varies every month and stops by the given (exclusive) end date. The function has the following syntax:
- TemporalMonthsSince(<start date>,<end date>)
For example, to determine the number of months a mobile phone contract has been in effect, you would write this rule in Word:
the number of months the mobile phone contract has been in effect = TemporalMonthsSince(the start date of the mobile phone contract, the current date)
The function returns a temporal value with the number of months incrementing on the date of each monthly change point
Where 'the start date of the mobile phone contract' is 31/08/2016 and the current date is 20/12/2016, the calculation of 'the number of months the mobile phone contract has been in effect' is shown in the following table.
| the start date of the mobile phone contract | Calculation Date | the number of months the mobile phone contract has been in effect |
|---|---|---|
| 31/08/2016 | 31/08/2016 | 0 |
| 30/09/2016 | 1 | |
| 31/10/2016 | 2 | |
| 30/11/2016 | 3 |
Note: Where the supplied date is after the 28th day of the month, and a subsequent month has fewer days than the supplied month, the change point for the anniversary month will be created on the last day of that month. For example, if the supplied date is 28, 29, 30 or 31 January 2017, the first change point will be 28 February 2017.