I really like the lubridate
package for this problem.
require(quantmod)
require(lubridate)
getSymbols("^STOXX50E", from = "1990-01-01")
maturity <- 9 # years
dates <- as.POSIXct(as.character(index(STOXX50E)), tz = "UTC") # needs to be in POSIXct format to work with lubridate, I believe.
maturity_dates <- dates + years(maturity)
head(as.data.frame(list(dates = dates,
maturity_dates = maturity_dates)))
dates maturity.dates
1 1990-01-01 1999-01-01
2 1990-01-02 1999-01-02
3 1990-01-03 1999-01-03
4 1990-01-04 1999-01-04
5 1990-01-05 1999-01-05
6 1990-01-08 1999-01-08