Extract the day, month or year of a date in a dplyr pipeline
Examples
if (FALSE) { # \dontrun{
con <- DBI::dbConnect(duckdb::duckdb(), ":memory:")
date_tbl <- dplyr::copy_to(con,
data.frame(birth_date = as.Date("1993-04-19")),
name = "tmp",
temporary = TRUE)
df <- date_tbl %>%
dplyr::mutate(year = !!datepart("birth_date", "year")) %>%
dplyr::mutate(month = !!datepart("birth_date", "month")) %>%
dplyr::mutate(day = !!datepart("birth_date", "day")) %>%
dplyr::collect()
DBI::dbDisconnect(con, shutdown = TRUE)
} # }