Reformat any date format (ISO8601 character string, POSIXt, or Date) to be a Date object
dateany_to_date.Rd
All values must be converted (without additional NA values created). For
character strings, the year-month-day part is required to be in ISO 8601
format, but the (ignored) time format only requires separation by a
"T"
.
See also
Other Date management and conversion:
generate_dtc()
,
is_ISO8601_calendar_datetime()
,
is_ISO8601_calendar_date()
,
is_ISO8601_ordinal_datetime()
,
is_ISO8601_timezone()
,
is_ISO8601_time()
,
is_ISO8601_week_datetime()
,
make_dy()
,
pattern_ISO8601_any_datetime()
,
pattern_ISO8601_any_date()
,
pattern_ISO8601_calendar_datetime()
,
pattern_ISO8601_calendar_date()
,
pattern_ISO8601_calendar_year()
,
pattern_ISO8601_ordinal_datetime()
,
pattern_ISO8601_ordinal_date()
,
pattern_ISO8601_timezone()
,
pattern_ISO8601_time()
,
pattern_ISO8601_week_datetime()
,
pattern_ISO8601_week_date()
,
sdtm_dtc_to_datetime()
,
sdtm_first_dose()
,
sdtm_time_actual()
Examples
dateany_to_date("2022-01-02")
#> [1] "2022-01-02"
dateany_to_date("2022-01-02T03:04") # the time part is automatically dropped
#> [1] "2022-01-02"
dateany_to_date(as.Date("2022-01-02"))
#> [1] "2022-01-02"
dateany_to_date(as.POSIXct("2022-01-02T03:04")) # the time part is still gone
#> [1] "2022-01-02"