I'm trying to calculate the difference-in-years between 2 dates.
time1 <- as.Date(x = "2017-02-14",
format = "%Y-%m-%d",
origin = "",
tz = "")
time2 <- as.Date(x = "1972-02-17",
format = "%Y-%m-%d",
origin = "",
tz = "")
as.integer(x = difftime(time1 = time1,
time2 = time2,
tz = "",
units = "days")) / 365
According to the above code, the difference-in-years is about 45.02466.
A glance at the 2 dates confirms that the difference-in-years is close to, but less than, 45.
The difference-in-years value should begin with 44.
Why is difftime
inflating the number of years by 1?