The number of months between datetimes.

Months = SRP_DateTime("MonthSpan", FromDateTime, ToDateTime, Fractional)

Returns

The number of months between two datetimes

Parameters

ParameterDescription
FromDateTimeA starting datetime in OI internal format. (REQUIRED)
ToDateTimeAn ending datetime in OI internal format. (REQUIRED)
FractionalDetermines if the span should be in whole months or fractional months. (OPTIONAL)

Remarks

The "MonthSpan" service calculates the number of months between two datetimes. The result will be positive if the starting datetime comes before the ending datetime and negative if the ending datetime comes first.

If Fractional is set to 1, which is the default, you will get a decimal number if the day or time of day are not the same for each datetime. 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 datetimes, then you will get a whole month (plus or minus the time of day). 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 datetime'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 datetimes
From = SRP_DateTime("Parse", "Monday, December 8, 1941 at 7:51:43am", "DDD, MMMM D, YYYY at h:mm:sstt")
To = SRP_DateTime("Parse", "Thursday, March 30, 1978 at 12:41:08pm", "DDD, MMMM D, YYYY at h:mm:sstt")
Months = SRP_DateTime("MonthSpan", From, To)

// Get the number of whole months
Months = SRP_DateTime("MonthSpan", From, To, 0)