AddMonthsYM

0th

Percentile

Add a Month to a Date

The format YYYYMM for dates can sometimes be convenient. Adding a number of months to such a date however is tedious, as the date structure should going to be preserved. Think of e.g. 201201 - 2 months, which would be expected to yield 201111. AddMonthsYM does this job.

Keywords
chron
Usage
AddMonthsYM(x, n)
Arguments
x
a vector of integers, representing the dates in the format YYYYMM, to which a number of months has to be added.
n
the number of months to be added. If n is negative the months will be subtracted.

Details

All parameters will be recyled if necessary. The therefore used function mapply will display a warning, if the longer argument is not a multiple of the length of the shorter one.

Value

integer with the same dimension as x, containing the transformed dates.

See Also

AddMonths; Date functions, like Year, Month, etc.

Aliases
  • AddMonthsYM
Examples
AddMonthsYM(201511, 5)

AddMonthsYM(c(201511, 201302), c(5, 15))
AddMonthsYM(c(201511, 201302), c(5, -4))
Documentation reproduced from package DescTools, version 0.99.19, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.