Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: ckapashiCalculating difference between two dates in terms of years using dateSubtract provides inconsistent output. See below for examples:
Example 1: Dt1 = 2007-10-22 and Dt2 = 2015-03-31. Using dateSubtract(d2,d1,"years") provides the output as 8 where the actual difference is 7 completed years.
Example 2: Dt1 = 2007-02-12 and Dt2 = 2015-03-31. Using dateSubtract(d2,d1,"years") provides the correct output of 8 years.
There is some inconsistency in terms of rounding up or down which I cannot figure out.
How to fix this issue to get the correct full completed years between two dates?