The number of months between dates.
Months = SRP_Date("MonthSpan", FromDate, ToDate, Fractional)
Returns
The number of months between two dates
Parameters
Parameter | Description |
---|---|
FromDate | A starting date in OI internal format. (REQUIRED) |
ToDate | An ending date in OI internal format. (REQUIRED) |
Fractional | Determines if the span should be in whole months or fractional months. (OPTIONAL) |
Remarks
The "MonthSpan" service calculates the number of months between two dates. The result will be positive if the starting date comes before the ending date and negative if the ending date comes first.
If Fractional is set to 1, which is the default, you will get a decimal number if the day of the months are not the same for each date. If you want whole months only, set Fractional to 0.
Months are an abstract concept, so calculating a fraction of a month gets interesting. If the day of the month is the same between dates, then you will get a whole number result. For example, calculating the span between February 28 and March 28 will return 1.0 as will the span between March 28 and April 28, even though there are only 28 days between the first pair and 31 days between the second. If the day of the months are different, then the fraction is based on the number of days in the earlier date's month. For example, March 30 to April 27 will return 0.903225806451612, for there are 31 days in march and 28 days between March 30 and April 27: thus, 28 / 31 is 0.903225806451612. April 30 to May 27 returns 0.933333333333333; a slightly different value because April only has 30 days. Thus, fractional months are useful for giving an approximate fractional span but should be considered as abstract as months themselves.
Examples
// Get the number of months between two dates From = SRP_Date("Parse", "Monday, December 8, 1941", "DDD, MMMM D, YYYY") To = SRP_Date("Parse", "Thursday, March 30, 1978", "DDD, MMMM D, YYYY") Months = SRP_Date("MonthSpan", From, To) // Get the number of whole months Months = SRP_Date("MonthSpan", From, To, 0)