The number of years between datetimes.
The number of years between two datetimes
|FromDateTime||A starting datetime in OI internal format. (REQUIRED)|
|ToDateTime||An ending datetime in OI internal format. (REQUIRED)|
|Fractional||Determines if the span should be in whole years or fractional years. (OPTIONAL)|
The "YearSpan" service calculates the number of years 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 month, day, or time of day are not the same for each datetime. If you want whole years only, set Fractional to 0.
Leap years make calculating a fraction of a year interesting. If the month, day, and time of day are the same between datetimes, then you will get a whole year. For example, the span between February 28, 2020 and February 28, 2021 is 1.0 as will the span between February 28, 2021 and February 28, 2022, even though there are 366 days between the first pair and 365 days between the second. If the month, day, or time of day are different, then the fraction is based on the number of seconds in the earlier datetime's year. For example, February 28, 2020 to January 30, 2021 will return 0.920765027322404, but February 28, 2020 to January 30, 2021 will return 0.920547945205479. That's because the first range comes to 337 days out of 366 and the second range is 336 days out of 365. Thus, fractional years should be treated as an approximate fractional span given the nature of leap years.