Provides the sql code to compute the age of a person on a given date.
Examples
conn <- SCDB::get_connection(drv = RSQLite::SQLite())
dplyr::copy_to(conn, data.frame(birth = as.Date("2001-04-03"), "test_age")) |>
dplyr::mutate(age = !!age_on_date("birth", as.Date("2024-02-28"), conn))
#> Warning: Age computation on SQLite is not precise. For some edge-cases, age will be off by 1 year! Consider using DuckDB as a local database with precise age computation.
#> Warning: Age computation on SQLite is not precise. For some edge-cases, age will be off by 1 year! Consider using DuckDB as a local database with precise age computation.
#> Warning: Age computation on SQLite is not precise. For some edge-cases, age will be off by 1 year! Consider using DuckDB as a local database with precise age computation.
#> # Source: SQL [1 x 3]
#> # Database: sqlite 3.47.1 [:memory:]
#> birth X.test_age. age
#> <dbl> <chr> <int>
#> 1 11415 test_age 22
DBI::dbDisconnect(conn)