Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 91bd4ee969
Fetching contributors…

Cannot retrieve contributors at this time

48 lines (45 sloc) 1.164 kb
\title{Round date-times up.}
unit = c("second", "minute", "hour", "day", "week", "month", "year"))
\item{x}{a vector of date-time objects}
\item{unit}{a character string specifying the time unit
to be rounded to. Should be one of
"second","minute","hour","day", "week", "month", or
x with the appropriate units rounded up
ceiling_date takes a date-time object and rounds it up to
the nearest integer value of the specified time unit.
Users can specify whether to round up to the nearest
second, minute, hour, day, week, month, or year.
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"
\code{\link{floor_date}}, \code{\link{round_date}}
Jump to Line
Something went wrong with that request. Please try again.