Please do not close this question as it is not a duplicate of How to subtract months from a date in R?
I am trying to convert a date of type IDate
to mondate
and then back to IDate
.
In the code below I am trying to get a date 6 months prior to the given date date1
, which is IDate object.
library(mondate)
date1 = as.IDate("2020-02-10")
date2 = as.IDate(mondate(date1)-6)
However, I am getting the warning
Warning message:
Attempting to convert class 'IDateDate' to 'mondate' via 'as.Date' then 'as.numeric'. Check results!
Can someone tell me how to correct this warning?
Solution -
As suggested by Ronak in comments - date1 %m-% months(6)
works just fine with IDate class.