
Extract Day, Month, and Year from Date Column
extract_date.RdThis function takes a column of dates that can be in various common formats, and extracts the day, month, and year, returning them in a data frame.
Examples
# mdy format
dates <- c("October 2, 2024", "10-02-2024", "10/02/2024")
result <- extract_date(dates, date_format = "mdy")
print(result)
#> day month year
#> 1 2 10 2024
#> 2 2 10 2024
#> 3 2 10 2024
dates <- c("2 October 2024", "02-10-2024", "02/10/2024")
result <- extract_date(dates, date_format = "dmy")
print(result)
#> day month year
#> 1 2 10 2024
#> 2 2 10 2024
#> 3 2 10 2024