Skip to contents

This function takes a date as input and returns the closest year.

Usage

find_closest_year(date)

Arguments

date

[character(1)]
The date in format "YYYY-MM-DD".

Value

An integer, the closest year to the input date.

See also

Other date helpers: check_date()

Examples

find_closest_year(as.Date("2022-07-15"))
#> [1] 2023
find_closest_year(as.Date("2022-01-01"))
#> [1] 2022