As title says, if you try to subtract one month with months(1) from a date, it will return NA if the date contains the 31st day, i.e on this very day where my program breaks as i have a today() - months(1) variable in a function.
This also occurs when doing as_date('2022-10-31') - months(1).
The problem seems to be that subtracting a month from the above date will return a date of 2022-09-31 which is an invalid date, hence the NA.
The workaround is to use days(30) or days(31) i guess, but i'm sure i'm not the first nor the last to hit this error (However, I couldn't find any issue on here reporting it.).
As title says, if you try to subtract one month with
months(1)
from a date, it will return NA if the date contains the 31st day, i.e on this very day where my program breaks as i have atoday() - months(1)
variable in a function.This also occurs when doing
as_date('2022-10-31') - months(1)
. The problem seems to be that subtracting a month from the above date will return a date of2022-09-31
which is an invalid date, hence theNA
.The workaround is to use
days(30)
ordays(31)
i guess, but i'm sure i'm not the first nor the last to hit this error (However, I couldn't find any issue on here reporting it.).