GAQL date ranges: DURING, BETWEEN and the predefined ranges
How to filter Google Ads queries by date, with the full list of predefined ranges and the common mistakes.
Most GAQL queries need a date filter. There are two ways to write one, both on segments.date.
Predefined ranges with DURING
SELECT campaign.name, metrics.cost_micros
FROM campaign
WHERE segments.date DURING LAST_30_DAYSThe ranges are:
TODAY,YESTERDAYLAST_7_DAYS,LAST_14_DAYS,LAST_30_DAYSTHIS_MONTH,LAST_MONTHLAST_BUSINESS_WEEKTHIS_WEEK_SUN_TODAY,THIS_WEEK_MON_TODAYLAST_WEEK_SUN_SAT,LAST_WEEK_MON_SUN
The "last N days" ranges end yesterday; they do not include today.
Explicit dates with BETWEEN
WHERE segments.date BETWEEN '2026-09-01' AND '2026-09-30'Dates are written YYYY-MM-DD in quotes, and both ends are included. A single day can be written as segments.date = '2026-09-15'.
Building dates in a script
There is no predefined range for "last 90 days" or "this quarter", so build the dates:
function daysAgo(n) {
var d = new Date();
d.setDate(d.getDate() - n);
return Utilities.formatDate(d, AdsApp.currentAccount().getTimeZone(), "yyyy-MM-dd");
}
var where = "segments.date BETWEEN '" + daysAgo(90) + "' AND '" + daysAgo(1) + "'";Format dates in the account's time zone, otherwise "yesterday" can be off by a day.
Common mistakes
- Selecting `segments.date` without filtering on it. If date is in
SELECT, a date filter is required. - Expecting totals when date is selected. With
segments.dateinSELECTyou get one row per day. Leave it out ofSELECT, keeping the filter, to get totals for the period. - Including today in a performance rule. Today's data is partial and conversions are still arriving.
- No date filter at all. Metrics then cover the account's whole history, which is rarely what you meant.
The Builder in GAQL Lab offers the predefined ranges in a dropdown.