Learn R Programming

eye (version 1.2.1)

getage: getage

Description

calculates age in years, as durations or periods

Usage

getage(from_date, to_date = lubridate::now(), period = FALSE, dec = 1)

Arguments

from_date

start date

to_date

end date

period

Calculating period (TRUE) or duration (FALSE- default)

dec

How many decimals are displayed

Value

Numeric vector

See Also

OP on stackoverflow from which this function was inspired. Read about periods and durations

Examples

Run this code
# NOT RUN {
getage("1984-10-16")

dob <-  c("1984-10-16", "2000-01-01")
test_date <-  as.Date(dob) + c(15000, 20000)
getage(dob, test_date)
# }

Run the code above in your browser using DataLab