Skip to main content

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.

Note

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.


Choose one time dimension for TIMESERIES. Time dimensions include intervals, such as day and month, and date or clock values, such as day_of_week and hour_of_day. Use GROUP BY with a time dimension when the result needs only values that exist in the data for that dimension.

Anchor to second
second
yyyy-MM-ddThh:mm:ss

Groups rows into one-second intervals.

Anchor to minute
minute
yyyy-MM-ddThh:mm

Groups rows into one-minute intervals.

yyyy-MM-ddThh

Groups rows into one-hour intervals.

yyyy-MM-dd

Groups rows into calendar days.

yyyy-MM-dd

Groups rows into calendar weeks.

Anchor to month
month
yyyy-MM-dd

Groups rows into calendar months.

Anchor to quarter
quarter
yyyy-MM-dd

Groups rows into calendar quarters.

yyyy-MM-dd

Groups rows into calendar years.

Anchor to hour_of_day
hour_of_day
0-23

Groups rows by hour of the day, combining that hour across all dates.

Anchor to day_of_week
day_of_week
0-6

Groups rows by day of the week, combining that weekday across all dates.

Anchor to week_of_year
week_of_year
1-53

Groups rows by week of the year, combining that week across years.

Anchor to month_of_year
month_of_year
1-12

Groups rows by month of the year, combining that month across years.


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 dimensionDefault range
secondSINCE startOfMinute(-1min) UNTIL now
minuteSINCE startOfHour(-1h) UNTIL now
hourSINCE startOfHour(-24h) UNTIL now
daySINCE startOfDay(-30d) UNTIL now
weekSINCE startOfWeek(-4w) UNTIL now
monthSINCE startOfMonth(-3m) UNTIL now
quarterSINCE startOfQuarter(-4q) UNTIL now
yearSINCE startOfYear(-3y) UNTIL now
hour_of_daySINCE startOfDay(-3d) UNTIL now
day_of_weekSINCE startOfWeek(-4w) UNTIL now
week_of_yearSINCE startOfYear(-1y) UNTIL now
month_of_yearSINCE startOfYear(-1y) UNTIL now

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 BY or SHOW, then it's the first dimension in the result.
  • If the time dimension is in GROUP BY, then its position follows the GROUP BY order.
  • If the time dimension is also in SHOW, then its position follows the SHOW order.

Was this page helpful?