age_years: Accurate and efficient age calculation

View source: R/age_years.R

age_yearsR Documentation

Accurate and efficient age calculation

Description

Correct calculation of ages in years using lubridate periods. Leap year calculations work as well.

Usage

age_years(start, end = if (is_date(start)) Sys.Date() else Sys.time())

age_months(start, end = if (is_date(start)) Sys.Date() else Sys.time())

Arguments

start

Start date/datetime, typically date of birth.

end

End date/datetime. Default is current date/datetime.

Value

Integer vector of age in years or months.


timeplyr documentation built on April 3, 2025, 6:15 p.m.