time {object}
The time property can be used to specify a time-based filter for a query.
In the Zoomdata application, the time bar
constructs this filter.
The time object contains the following properties:
- timeField {string}: Field name used for the time filter
- from {string}: Sets the starting point of the time range used in the filter. Use the format
[+/-]YYYY-MM-DD HH:mm:ss.SSS
or a[+]dynamic time preset
string. - to {string}: Sets the ending point of the time range used in the filter. Use the format
[+/-]YYYY-MM-DD HH:mm:ss.SSS
or or a[+]dynamic time preset
string.
The +
or -
modifiers at the beginning of a timestamp string can be used to include or exclude the specified timestamp up to the millisecond.
For example, if the time range should include all of December 25 2017 - December 31 2017, you could set the from
to +2017-12-25 00:00:000
and the to
property to -2018-01-00 00:00:000
or +2017-12-31 11:59:999
.
Dynamic Time Presets
When setting the from
and to
properties of the time object, you can use the following dynamic time preset strings:
- $now
- $start_of_data
- $start_of_year
- $start_of_quarter
- $start_of_month
- $start_of_week
- $start_of_day
- $start_of_hour
- $end_of_data
- $end_of_year
- $end_of_quarter
- $end_of_month
- $end_of_week
- $end_of_day
- $end_of_hour
The dynamic time preset strings can also be combined with a time modifier to add
or subtract
time from the resolved preset.
The following time modifiers are valid:
- [+/-]x_year
- [+/-]x_quarter
- [+/-]x_month
- [+/-]x_week
- [+/-]x_day
- [+/-]x_hour
where any number can replace x
.
A few examples:
- $now_-365_day
- $start_of_year_+1_month
- $end_of_data_-1_day
Example:
const time = {
from: '+2009-01-20 00:00:00.000',
timeField: 'transaction_date',
to: '+$end_of_data_-1_day',
};
Try this example on CodeSandbox
Updated Jan 10, 2019