parse_date_chr: Parse raw strings as dates (days since 1970-01-01)

View source: R/parse.r

parse_date_chrR Documentation

Parse raw strings as dates (days since 1970-01-01)

Description

Recognises ISO yyyy-mm-dd (with optional time), yyyy.mm.dd., yyyy/mm/dd, dd.mm.yyyy and, when allow_serial = TRUE, Excel date serials (numbers between 3000 and 73000, i.e. 1908 to 2099).

Usage

parse_date_chr(x, allow_serial = FALSE)

Arguments

x

Character vector.

allow_serial

Logical; treat plausible numbers as Excel serials.

Value

Numeric vector of days since 1970-01-01, NA if not a date.

Examples

x <- c("2020-01-15", "16.01.2020", "2020/01/17", "43848", NA)
days <- parse_date_chr(x)
as.Date(days, origin = "1970-01-01")
days <- parse_date_chr(x, allow_serial = TRUE)
as.Date(days, origin = "1970-01-01")

cellsynth documentation built on Oct. 31, 2026, 1:07 a.m.