View source: R/sql_expressions.R
hsSqlExTimeCond | R Documentation |
WHERE-condition string in MS Jet SQL syntax filtering for a specific time interval
hsSqlExTimeCond(
tsField,
dateFirst = NULL,
dateLast = NULL,
inclLast = TRUE,
sqlDialect = getCurrentSqlDialect(),
dbg = FALSE
)
tsField |
name of timestamp field |
dateFirst |
Date object representing the first date of the time interval to be selected. |
dateLast |
Date object representing the last date of the time interval to be selected. |
inclLast |
if |
sqlDialect |
one of |
dbg |
if |
Condition string in MS Jet SQL syntax to be used in WHERE clause
hsJetDate
## Not run:
## Condition string to filter field "datetime" for timestamps
## between 21 and 22 of July 2010
from <- as.Date("2011-08-23")
to <- as.Date("2011-08-24")
cond <- hsSqlExTimeCond("Zeitst", from, to)
cond
## Output:
# TRUE AND Zeitst >= #08/23/2011 00:00:00#
# AND Zeitst <= #08/24/2011 00:00:00#
## The condition string may now be used in an SQL query
## to select data from within the time interval.
sql <- sprintf("SELECT * FROM tbl_Hyd WHERE %s", cond)
if (.Platform$OS.type == "windows") {
res <- hsSqlQuery(xmdb(), sql)
head(res)
}
## Output:
# Zeitst Q v H T_Kanal
# 1 2011-08-23 00:00:00 0 0 1.260 19.5
# 2 2011-08-23 00:01:00 0 0 1.259 19.5
# 3 2011-08-23 00:02:00 0 0 1.259 19.5
# 4 2011-08-23 00:03:00 0 0 1.259 19.5
# 5 2011-08-23 00:04:00 0 0 1.260 19.5
# 6 2011-08-23 00:05:00 0 0 1.260 19.5
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.