TIMESERIES
Use TIMESERIES to return results by one time dimension across a date range. Time dimensions include intervals, such as day and month, and date or clock values, such as day_of_week and hour_of_day. Use TIMESERIES when the result should show every value of the selected time dimension in the reporting period.
Use SHOW to choose returned columns, GROUP BY to add dimensions, and SINCE, UNTIL, or DURING to set the reporting period. Use VISUALIZE to add a chart that needs a time axis.
A time dimension in GROUP BY without TIMESERIES groups results by time, but returns only values that exist in the data for that time dimension.
A time dimension in GROUP BY without TIMESERIES groups results by time, but returns only values that exist in the data for that time dimension.
Anchor to Time dimensionsTime dimensions
Choose one time dimension for TIMESERIES. Time dimensions include intervals, such as day and month, and date or clock values, such as and . Use GROUP BY with a time dimension when the result needs only values that exist in the data for that dimension.
- Anchor to secondsecondsecondyyyy-MM-ddThh:mm:ssyyyy-MM-ddThh:mm:ss
Groups rows into one-second intervals.
- Anchor to minuteminuteminuteyyyy-MM-ddThh:mmyyyy-MM-ddThh:mm
Groups rows into one-minute intervals.
- Anchor to hourhourhouryyyy-MM-ddThhyyyy-MM-ddThh
Groups rows into one-hour intervals.
- Anchor to daydaydayyyyy-MM-ddyyyy-MM-dd
Groups rows into calendar days.
- Anchor to weekweekweekyyyy-MM-ddyyyy-MM-dd
Groups rows into calendar weeks.
- Anchor to monthmonthmonthyyyy-MM-ddyyyy-MM-dd
Groups rows into calendar months.
- Anchor to quarterquarterquarteryyyy-MM-ddyyyy-MM-dd
Groups rows into calendar quarters.
- Anchor to yearyearyearyyyy-MM-ddyyyy-MM-dd
Groups rows into calendar years.
- Anchor to hour_of_dayhour_
of_ dayhour_ of_ day 0-230-23 Groups rows by hour of the day, combining that hour across all dates.
- Anchor to day_of_weekday_
of_ weekday_ of_ week 0-60-6 Groups rows by day of the week, combining that weekday across all dates.
- Anchor to week_of_yearweek_
of_ yearweek_ of_ year 1-531-53 Groups rows by week of the year, combining that week across years.
- Anchor to month_of_yearmonth_
of_ yearmonth_ of_ year 1-121-12 Groups rows by month of the year, combining that month across years.
Anchor to Default date rangesDefault date ranges
When a query uses TIMESERIES without explicit date bounds, ShopifyQL applies a default reporting period based on the selected time dimension. If you omit SINCE and the query doesn't use DURING, then ShopifyQL applies the default start date for that time dimension. If you omit UNTIL and the query doesn't use DURING, then ShopifyQL uses now as the end date. To set the reporting period explicitly, use SINCE, UNTIL, or DURING.
The following table lists the default range that each time dimension applies:
| Time dimension | Default range |
|---|---|
second | SINCE startOfMinute(-1min) UNTIL now |
minute | SINCE startOfHour(-1h) UNTIL now |
hour | SINCE startOfHour(-24h) UNTIL now |
day | SINCE startOfDay(-30d) UNTIL now |
week | SINCE startOfWeek(-4w) UNTIL now |
month | SINCE startOfMonth(-3m) UNTIL now |
quarter | SINCE startOfQuarter(-4q) UNTIL now |
year | SINCE startOfYear(-3y) UNTIL now |
hour_of_day | SINCE startOfDay(-3d) UNTIL now |
day_of_week | SINCE startOfWeek(-4w) UNTIL now |
week_of_year | SINCE startOfYear(-1y) UNTIL now |
month_of_year | SINCE startOfYear(-1y) UNTIL now |
Anchor to Result columnsResult columns
TIMESERIES adds the selected time dimension to the returned columns. Where the time dimension appears depends on whether you also reference it in SHOW or GROUP BY:
- If the time dimension isn't in
GROUP BYorSHOW, then it's the first dimension in the result. - If the time dimension is in
GROUP BY, then its position follows theGROUP BYorder. - If the time dimension is also in
SHOW, then its position follows theSHOWorder.