sm_as_date {samadb} | R Documentation |
Coerce Vectors to Dates
Description
This function coerces date strings i.e. "YYYY-MM-DD"
or "YYYY-MM"
, years e.g. 2015
(numeric or character),
year-quarters e.g. "2015Q1"
or "2015-Q1"
, year-months e.g. "2015M01"
or "2015-M01"
or numeric values representing dates (e.g. previously imported Excel date) to a regular R date.
Usage
sm_as_date(x, end = FALSE, origin = "1899-12-30")
Arguments
x |
a character date string |
end |
logical. |
origin |
a date or date-string that can be used as reference for converting numeric values to dates. The default corresponds to dates generated in Excel for Windows. See |
Value
A Date
vector.
See Also
Examples
sm_as_date("2011-05")
sm_as_date(2011)
sm_as_date("2011Q1")
sm_as_date("2011Q1", end = TRUE)
sm_as_date("2011M2")
sm_as_date("2011M2", end = TRUE)