Last chance! 50% off unlimited learning
Sale ends in
ceiling_date(x,
unit = c("second", "minute", "hour", "day", "week", "month", "year"))
floor_date
, round_date
x <- as.POSIXct("2009-08-03 12:01:59.23")
ceiling_date(x, "second")
# "2009-08-03 12:02:00 CDT"
ceiling_date(x, "minute")
# "2009-08-03 12:02:00 CDT"
ceiling_date(x, "hour")
# "2009-08-03 13:00:00 CDT"
ceiling_date(x, "day")
# "2009-08-04 CDT"
ceiling_date(x, "week")
# "2009-08-09 CDT"
ceiling_date(x, "month")
# "2009-09-01 CDT"
ceiling_date(x, "year")
# "2010-01-01 CST"
Run the code above in your browser using DataLab