Filtering by Day of Week or Hour of Day
You can add an expression to the predicate of a tsquery statement that limits the stream to specified days of the week or to a range of hours in each day.
By Day – Limits the stream to selected days of the week.
The
day in ()
expression
takes an argument with a comma-separated list of days of the week, enclosed in parentheses.
The days of the week are numbered 1 through 7; 1 = Monday, 2 = Tuesday, and so on. Use the
following
syntax:day in (#, #, ...)
For example, the following expression limits the stream to events that
occurred only on
weekdays:
day in (1,2,3,4,5)
By Hour – Limits the stream to a range of hours each day.
The
hour in
expression
takes an argument with a range of hours separated by a colon and enclosed in square brackets.
Valid values are integers
0–23:hour in [#:#]
For example, the following expression limits the stream to events that
occur only between 9:00 a.m. and 5:00
p.m.:
hour in [9:17]
Add the day or time range expression after the WHERE
clause. Do not use the AND
keyword. For example:
select fd_open where category = ROLE and roleType = SERVICEMONITOR day in (1,2,3,4,5)
You can also combine
day
in
and hour in
expressions. Always
put the day
expression before the hour
expression. The following example limits the
stream to weekdays between 9:00 a.m. and 5:00
p.m.:select fd_open where category = ROLE and roleType = SERVICEMONITOR day in (1,2,3,4,5) hour in [9:17]