Add a month to a Date [duplicate]

Function %m+% from lubridate adds one month without exceeding last day of the new month.

library(lubridate)
(d <- ymd("2012-01-31"))
 1 parsed with %Y-%m-%d
[1] "2012-01-31 UTC"
d %m+% months(1)
[1] "2012-02-29 UTC"

Leave a Comment