Check that a vector conforms to a given date format such as YYYYMMDD.

chk_date_yyyymmdd(x)

chk_date_yyyymm(x)

chk_date_yyyy(x)

Arguments

x

A vector to check.

Value

A logical vector flagging records that have passed or failed the check.

Examples


date <- c(20210101, 20211301, 20210132, 202101, 2021)
chk_date_yyyymmdd(date)
#> [1]  TRUE FALSE FALSE FALSE FALSE

date <- c(202101, 202112, 202113, 2021)
chk_date_yyyymm(date)
#> [1]  TRUE  TRUE FALSE FALSE

date <- c("0001", "1688", "1775", "1789", "1791", "1848")
chk_date_yyyy(date)
#> [1] TRUE TRUE TRUE TRUE TRUE TRUE