Learn R Programming

diseasystore (version 0.3.1)

add_years: Backend-dependent time interval (in years)

Description

Provides the sql code for a time interval (in years).

Usage

add_years(reference_date, years, conn)

Value

SQL query for the time interval.

Arguments

reference_date

(Date(1) or character(1))
The date to add years to (or name of column containing the reference date).

years

(numeric(1) or character(1))
The length of the time interval in whole years (or name of column containing the number of years).

conn

(DBIConnection or function)
A database connection or function that opens a database connection.

Examples

Run this code
if (FALSE) { # requireNamespace("RSQLite", quietly = TRUE)
  conn <- SCDB::get_connection(drv = RSQLite::SQLite())

  dplyr::copy_to(conn, data.frame(birth = as.Date("2001-04-03"), "test_age")) |>
    dplyr::mutate(first_birthday = !!add_years("birth", 1, conn))

  DBI::dbDisconnect(conn)
}

Run the code above in your browser using DataLab