date_between {lazysql}R Documentation

Create SQL string to select date between two given dates

Description

Create string with SQL BETWEEN expression for WHERE clause to select dates within the given range.

Usage

date_between(column_name, date_range)

Arguments

column_name

[character(1)]
Name of data base column to select dates from.

date_range

[Date(1:2)]
One or two dates giving the date range in which the dates should be enclosed (closed interval). If only one date is given, it is taken for both upper and lower limits.

Details

column_name must be a valid SQL identifier. It is validated to conform to the regular expression returned by valid_identifier_regex.

Value

Character string to be used in SQL statement.

Author(s)

Uwe Block

See Also

valid_identifier_regex.

Examples

date1 <- as.Date("2016-02-22")
date2 <- as.Date("2016-02-11")

# SQL expression for a date range
(sql_expr1 <- lazysql::date_between("STD_1", c(date1, date2)))

# SQL expression for a single date
(sql_expr2 <- lazysql::date_between("STD_1", date1))

# sample SQL statements
paste("select * from TEST_TABLE where", sql_expr1)

paste("select * from TEST_TABLE where", sql_expr2)


[Package lazysql version 0.1.3 Index]