powered by
This function takes a date as input and returns the closest year.
find_closest_year(date)
An integer, the closest year to the input date.
integer
A date in the format of "YYYY-MM-DD".
date
"YYYY-MM-DD"
find_closest_year(as.Date("2022-07-15")) find_closest_year(as.Date("2022-01-01"))
Run the code above in your browser using DataLab