Add a number of months to a date. In case the number is negative, the months will be subtracted.
A ceiling to the last available day of the month can be set. The function will then
yield as.Date('2013-01-31') + 1 month = '2013-02-28'.
Usage
AddMonths(x, n, ceiling = TRUE)
Arguments
x
the date to which a number of months has to be added. x can be a date or an integer.
If it is an integer it will be interpreted as yyyymm.
n
the number of months to be added. If n is negative the months will be subtracted.
ceiling
logic. If set to TRUE (default), a ceiling to the last available day of month will be set.
Value
a vector with the same dimension and type as x, containing the transformed dates.
References
Thanks to Antonio: http://stackoverflow.com/questions/14169620/add-a-month-to-a-date