GAQL query is working for predefined date ranges but not for custom date range

547 views
Skip to first unread message

Hema Sai Mamidi

unread,
Jul 26, 2022, 3:51:03 PM7/26/22
to Google Ads API and AdWords API Forum
Hi Team

I'm trying to get the data based on  the date range. The following query is working fine if I'm specifying the predefined date ranges like LAST_MONTH, LAST_7_DAYS. But, giving an error while trying to give the custom date ranges for "segments.date" . Could you pls let me know what is causing the issue and if you can provide the working query for the below example with custom date range will really help. TIA!


curl -f --request POST "https://googleads.googleapis.com/v11/customers/3659251597/googleAds:searchStream" --header "login-customer-id:4382929747" --header "Content-Type: application/json" --header 'developer-token: ${dev_token}' --header 'Authorization: Bearer '${access_token}'' --data '{ "query": "select metrics.clicks, segments.device, segments.day_of_week, segments.month_of_year FROM campaign WHERE metrics.clicks > 0 AND segments.date DURING LAST_MONTH LIMIT 10" }'

charlesb...@gmail.com

unread,
Jul 26, 2022, 5:33:19 PM7/26/22
to Google Ads API and AdWords API Forum
Hi,

There's no "DURING" with GAQL.

Try the GAQL query validator.

Google Ads API Forum Advisor

unread,
Jul 26, 2022, 11:12:14 PM7/26/22
to charlesb...@gmail.com, adwor...@googlegroups.com
Hi all,

Thank you for reaching us out. I am Sherwin from Google Ads API support team. I hope that you are doing well today.

Moving forward to your concern. For us to further investigate, could you please provide us the complete request and response logs with request ID and request header generated on your end when you are trying to fetch a campaign report. You can provide it via Reply privately to the author option. If this option is not available, then send it instead on this email address googleadsa...@google.com.

Kind regards,
Google Logo
Sherwin Vincent
Google Ads API Team
 


ref:_00D1U1174p._5004Q2d1l1k:ref

Google Ads API Forum Advisor

unread,
Jul 26, 2022, 11:20:33 PM7/26/22
to hema21...@gmail.com, adwor...@googlegroups.com

Roy Steves

unread,
Mar 13, 2023, 4:37:48 PM3/13/23
to Google Ads API and AdWords API Forum
Maybe there wasn't at the time, but there sure is now.

There is according to the examples here: 

I haven't found the list of acceptable values yet, so maybe that documentation is out of date, but it is for the current version of the API.

This validated, for example:
SELECT
  campaign.id,
  campaign.name,
  campaign.status,
  metrics.impressions,
  segments.date
FROM campaign
WHERE campaign.status = 'PAUSED'
  AND metrics.impressions > 1000
  AND segments.date during LAST_30_DAYS
ORDER BY campaign.id

Roy Steves

unread,
Mar 13, 2023, 4:43:02 PM3/13/23
to Google Ads API and AdWords API Forum
Found the list of current values: 
https://developers.google.com/google-ads/api/docs/query/date-ranges

And the reason that the documentation said that "DURING" was deprecated was that it was describing the sunset of the independent clause, but it's been replaced with an operator.

So, it's like "during" used to be a sibling to WHERE (like sort order and group by in SQL), but now it's part of the WHERE clause itself.  That change is documented here:
https://developers.google.com/google-ads/api/docs/migration/querying

Relevant excerpt: "Date filtering is different. There is no longer a DURING clause; instead, DURING is an operator that can be used in WHERE clauses. Filter the field date using the DURING clause for the same functionality as the DURING clause in AWQL."

Google Ads API Forum Advisor

unread,
Mar 14, 2023, 6:18:17 AM3/14/23
to r...@statbid.com, adwor...@googlegroups.com
Hi Roy,

You have now reached the Google Ads API Forum. We hope you are doing well today.

Thank you for your clarification and providing information regarding Google Ads API. Could you please confirm if you still need support from us? Also, from the initial response that you mentioned that you encountered an error. With this, could you please the complete API logs within the format of request and response logs with the request ID that generated on your end where we can see the error?

If you haven't yet, logging can be enabled by navigating to the Client libraries > Your client library (ex. Java) > Logging documentation, which you can access from this link. I ask this so that we can provide accurate recommendations here. 

For security purposes, you can provide it via the Reply privately to author option. If this option is not available, then send it instead on this email address googleadsapi-support@google.com.

Best regards,

Google Logo Google Ads API Team


 

ref:_00D1U1174p._5004Q2jZDCV:ref
Reply all
Reply to author
Forward
0 new messages