date_between: Create SQL string to select date between two given dates

Description Usage Arguments Details Value Author(s) See Also Examples

Description

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

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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)

lazysql documentation built on May 1, 2019, 9:45 p.m.