Skip to main content

Date ranges and presets

Date presets filter to a window like the last 30 days without typing dates. See each preset and the days it covers, other date conditions, time zones, and how to use presets in formulas.

B
Written by Bradley Taylor

Date presets filter to a common window, such as the last 30 days or last month, without typing dates. The same presets work in the Query Builder, in custom functions, and with the AI agent, and they always cover the same days.

Date presets

Every preset counts today as a full day and uses your store's time zone. The examples assume today is October 14, 2026.

Preset

In formulas

Covers

Example

Last 7 days

last_7d

Today and the 6 days before it

Oct 8 to Oct 14

Last 30 days

last_30d

Today and the 29 days before it

Sep 15 to Oct 14

This month

this_month

The 1st of this month through today

Oct 1 to Oct 14

Last month

last_month

All of the previous calendar month

Sep 1 to Sep 30

Year to date

ytd

January 1 of this year through today

Jan 1 to Oct 14

Trailing 12 months

trailing_12m

Today and the 12 months before it

Oct 15, 2025 to Oct 14, 2026

Other date conditions

When no preset fits, choose another condition on a date field.

Condition

Covers

on

The whole day you pick

before

Days before the date you pick, not including it

after

Days after the date you pick, not including it

between

Both dates you pick and every day in between

in the last

A window you set, such as 14 days or 6 months, ending today and including it

Time zones

Dates use your store's time zone, the one set in your Shopify admin. An order placed at 11:30 PM in your store's time zone counts on that day, wherever you open the workbook. If you connect stores in different time zones, each store's orders use its own time zone.

How presets stay current

Presets move with the calendar. A saved query or formula set to Last 30 days covers a new 30 days each time you refresh it, so you don't have to edit dates. Use between with fixed dates when you need a window that never moves, such as a past quarter.

Using presets in formulas

Custom functions use the names in the In formulas column. For example, this formula pulls order lines from the last 30 days:

=MS.QUERY("order_lines", "ordered_at,sku,net_sales", "ordered_at:last_30d")

MS.QUERY covers the full formula syntax.

Did this answer your question?