AsDate | R Documentation |
Parse dates assuming some common (unknown) formats popular either in the U.S. or internationally
AsDate(x, us.format = NULL, exact = FALSE, on.parse.failure = "error")
ParseDates(x, us.format = NULL)
x |
character; vector of dates or date intervals/periods to be parsed, which
should all be in the same format (excluding missing values). If timestamps are
detected, they will be parsed using |
us.format |
logical; whether to use the US convention for dates; can be |
exact |
see |
on.parse.failure |
Character string specifying how parse failures should be handled;
|
Time intervals or periods (start and end dates
representing a specific time span) are also supported. If periods
are detected in x
, the starting date is parsed to class
"Date"
and returned. A wide-range of separators are
supported and days are optional. The starting year also does not
need to be supplied, though for numeric months, the format must be
exactly ‘"%m/%m %y’ or ‘"%m-%m %y"’ (four-digit years
will also work). See the examples.
ParseDates
is deprecated and merely calls AsDate
A vector of Date
objects, if all elements of x
have
the same, valid format; otherwise, when on.parse.failure
is not
"error"
, a vector of NA values with the same length as x
.
Date
AsDate("1-2-2017", us.format = FALSE)
AsDate("1-2-2017", us.format = TRUE)
AsDate("10/16/2016-2/10/2017")
AsDate("jun/sep 10")
AsDate("10-02 2011")
AsDate("10/02/2011", us.format = TRUE)
AsDate("feb 2016-jan 2017")
AsDate("31-05-2010 16-08-2011")
AsDate("2010-February")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.