Closed lkoppers closed 1 year ago
The expected result is NA
> as.Date("2020-02-29") - years(1)
[1] NA
It's because 2019-02-29 does not exist. If you want a different behavior use either %m+%
or add_with_rallback()
function
> as.Date("2020-02-29") %m-% years(1)
[1] "2019-02-28"
> add_with_rollback(as.Date("2020-02-29"), -years(1))
[1] "2019-02-28"
In older versions of R as.Date("2020-02-29") - years(1) results to NA what can be expected. In R 4.2.2 the result is "1970-01-29"