Time criteria in AQL queries
Define time intervals in your AQL queries by using START and STOP clauses, or use the LAST clause for relative time references.
Define the time settings that are passed to the AQL query
The SELECT statement supports an arieltime option, which overrides the time settings.
You can limit the time period for which an AQL query is evaluated by using the following clauses and functions:
START
You can pass a time interval to
START
selecting data (from time), in the following formats:
yyyy-MM-dd HH:mm
yyyy-MM-dd HH:mm:ss
yyyy/MM/dd HH:mm:ss
yyyy/MM/dd-HH:mm:ss
yyyy:MM:dd-HH:mm:ss
The
timezone is represented by '
Use
z
or Z
' in the
following
formats:yyyy-MM-dd HH:mm'Z'
yyyy-MM-dd HH:mm'z'
START
in combination with STOP
.- Examples
-
Returns results from: 2014-04-25 15:51:00 to 2014-04-25 16:59:59SELECT * FROM events WHERE userName IS NULL START '2014-04-25 15:51' STOP '2014-04-25 17:00'
STOP
You can pass a time interval to
STOP
selecting data (end time), in the following formats:
yyyy-MM-dd HH:mm
yyyy-MM-dd HH:mm:ss
yyyy/MM/dd HH:mm:ss
yyyy/MM/dd-HH:mm:ss
yyyy:MM:dd-HH:mm:ss
The
timezone is represented by '
Use
z
or Z
' in the
following
formats:yyyy-MM-dd HH:mm'Z'
yyyy-MM-dd HH:mm'z'
STOP
in combination with START
.- Examples
-
SELECT * FROM events WHERE username IS NULL START '2016-04-25 14:00' STOP '2016-04-25 16:00'
LAST
You can pass a time interval to the LAST
clause to specify a specific time to
select data from.
The valid intervals are MINUTES, HOURS, and DAYS
- Examples
-
SELECT * FROM events LAST 15 MINUTES
Note: If you use a LIMIT clause in your query, you must place it before START
and STOP clauses, for example,
SELECT *
FROM events
LIMIT 100
START '2016-06-28 10:00'
STOP '2016-06-28 11:00'
Time functions
Use the following time functions to specify the parse time for the query.
NOW
- Purpose
- Returns the current time that is expressed as milliseconds since the time 00:00:00 Coordinated Universal Time (UTC) on January 1, 1970.
- Example
-
SELECT ASSETUSER(sourceip, NOW()) AS 'Asset user' FROM events
PARSEDATETIME
- Purpose
- Pass a time value to the parser, for example,
PARSEDATETIME('time reference')
. This'time reference'
is the parse time for the query.
- Example
-
SELECT * FROM events START PARSEDATETIME('1 hour ago')