new_interval(ymd(20090201), ymd(20090101))
# 2009-01-01 -- 2009-02-01
date1 <- as.POSIXct("2009-03-08 01:59:59")
date2 <- as.POSIXct("2000-02-29 12:00:00")
new_interval(date2, date1)
# 2000-02-29 12:00:00 -- 2009-03-08 01:59:59
new_interval(date1, date2)
# 2000-02-29 12:00:00 -- 2009-03-08 01:59:59
span <- new_interval(ymd(20090201), ymd(20090101))
# [1] 2009-01-01 -- 2009-02-01
span - days(30)
# 2009-01-01 -- 2009-01-02
span + months(6)
# 2009-01-01 -- 2009-08-01
start <- attr(span, "start")
# "2009-01-01 UTC"
end <- start + span
# "2009-02-01 UTC"}
Run the code above in your browser using DataLab