Specifying a Date Range
Relative date ranges
Report queries have a date_range
field for specifying the dates for which to include
data in the report. The following values can be specified for date_range
:
TODAY
YESTERDAY
MONTH_TO_DATE
YEAR_TO_DATE
LAST_7_DAYS
LAST_30_DAYS
CUSTOM
Note that the default date range if none is specified is CUSTOM
.
Custom date ranges
When date_range
is set to CUSTOM
or is
unspecified, you must set start_date
and end_date
to
the (inclusive) start and end dates of the report range.
In your API request's query parameters, the start date parameters will look like this:
startDate.year=2021&startDate.month=3&startDate.day=1
Similarly, the end date parameters will look like this:
endDate.year=2021&endDate.month=3&endDate.day=3
Next steps
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-08-21 UTC.
[null,null,["Last updated 2024-08-21 UTC."],[[["AdSense report queries use a `date_range` field to specify the timeframe for included data, accepting values such as `TODAY`, `YESTERDAY`, or various relative ranges."],["For custom date ranges, set `date_range` to `CUSTOM` and specify the inclusive start and end dates using `start_date` and `end_date` parameters."],["Custom start and end dates are defined by separate parameters for year, month, and day, formatted like `startDate.year=2021&startDate.month=3&startDate.day=1`."]]],["Report queries utilize a `date_range` field to define data inclusion periods. Available options are `TODAY`, `YESTERDAY`, `MONTH_TO_DATE`, `YEAR_TO_DATE`, `LAST_7_DAYS`, `LAST_30_DAYS`, and `CUSTOM`. The default is `CUSTOM`. When `CUSTOM` is used, `start_date` and `end_date` parameters are mandatory, set via `startDate.year`, `startDate.month`, `startDate.day` and `endDate.year`, `endDate.month`, `endDate.day` in the API request query.\n"]]