-
Notifications
You must be signed in to change notification settings - Fork 233
Time Filter
Hongzheng Shi edited this page Dec 3, 2018
·
1 revision
Time filters in AQL are used to specify ranges of time to query for. A time filter expression (in either from
, or to
) is specified in one of the following ways:
- Absolute time. The start of the specified time period is used in
from
; the end is used into
. Here are some examples:
Expression | Meaning when used in from
|
Meaning when used in to
|
---|---|---|
2016 |
>=2016-01-01 00:00 | <2017-01-01 00:00 |
2016-Q1 |
>=2016-01-01 00:00 | <2016-04-01 00:00 |
2016-01 |
>=2016-01-01 00:00 | <2016-02-01 00:00 |
2016-01-06 |
>=2016-01-06 00:00 | <2016-01-07 00:00 |
2016-01-06 14 |
>=2016-01-06 14:00 | <2016-01-06 15:00 |
2016-01-06 14:37 |
>=2016-01-06 14:37 | <2016-01-06 14:38 |
- Current time. The start of the specified time period is used in
from
; the end is used into
. Here are some examples:
Expression | Meaning when used in from
|
Meaning when used in to
|
---|---|---|
this year / 0y
|
>=2016-01-01 00:00 | <2017-01-01 00:00 |
this quarter / 0q
|
>=2016-01-01 00:00 | <2016-04-01 00:00 |
this month / 0M
|
>=2016-01-01 00:00 | <2016-02-01 00:00 |
this week / 0w
|
>=2016-01-04 00:00 | <2016-01-11 00:00 |
this day / today / 0d
|
>=2016-01-06 00:00 | <2016-01-07 00:00 |
this hour / 0h
|
>=2016-01-06 14:00 | <2016-01-06 15:00 |
this quarter-hour |
>=2016-01-06 14:30 | <2016-01-06 14:45 |
this minute / 0m
|
>=2016-01-06 14:37 | <2016-01-06 14:38 |
now |
>=2016-01-06 14:37 | <2016-01-06 14:37 |
- Time relative to now in the past. The start of the specified time period is used in
from
; the end is used into
. Here are some examples:
Expression | Meaning when used in from
|
Meaning when used in to
|
---|---|---|
last year / -1y
|
>=2015-01-01 00:00 | <2016-01-01 00:00 |
2 years ago / -2y
|
>=2014-01-01 00:00 | <2015-01-01 00:00 |
last quarter / -1q
|
>=2015-10-01 00:00 | <2016-01-01 00:00 |
2 quarters ago / -2q
|
>=2015-07-01 00:00 | <2015-10-01 00:00 |
last month / -1M
|
>=2015-12-01 00:00 | <2016-01-01 00:00 |
2 months ago / -2M
|
>=2015-11-01 00:00 | <2015-12-01 00:00 |
last week / -1w
|
>=2015-12-28 00:00 | <2016-01-04 00:00 |
2 weeks ago / -2w
|
>=2015-12-21 00:00 | <2015-12-28 00:00 |
last day / yesterday / -1d
|
>=2016-01-05 00:00 | <2016-01-06 00:00 |
2 days ago / -2d
|
>=2016-01-04 00:00 | <2016-01-05 00:00 |
last hour / -1h
|
>=2016-01-06 13:00 | <2016-01-06 14:00 |
2 hours ago / -2h
|
>=2016-01-06 12:00 | <2016-01-06 13:00 |
last quarter-hour |
>=2016-01-06 14:15 | <2016-01-06 14:30 |
2 quarter-hours ago |
>=2016-01-06 14:00 | <2016-01-06 14:15 |
last minute / -1m
|
>=2016-01-06 14:36 | <2016-01-06 14:37 |
2 minutes ago / -2m
|
>=2016-01-06 14:35 | <2016-01-06 14:36 |
Notice that the expressions of From
/To
: N $unit ago
doesn’t match exactly with the natural language where the boundary of the range starts/stops at exactly the specified duration ago. Instead it always include more than that: from: N $unit ago
will start the range at the last aligned $unit
before the specified duration ago; to: N $unit ago
will end the range at the first aligned $unit
after the specified duration ago. With this expression the same duration specified in different units will have different effects. For instance, if now is 2016-01-06 14:37, then:
from Expression |
Meaning |
to Expression |
Meaning |
---|---|---|---|
2 hours ago |
starting at 2016-01-06 12:00 | 2 hours ago |
ending at 2016-01-06 13:00 |
120 minutes ago |
starting at 2016-01-06 12:37 | 120 minutes ago |
ending at 2016-01-06 12:38 |
2 months ago |
starting at 2015-11-01 | 2 months ago |
ending at 2015-12-01 |
61 days ago |
starting at 2015-11-06 | 61 days ago |
ending at 2015-11-07 |
2 years ago |
starting at 2014-01-01 | 2 years ago |
ending at 2015-01-01 |
730 days ago |
starting at 2014-01-06 | 730 days ago |
ending at 2014-01-07 |