Proper way to write a subquery on GQL

25 views
Skip to first unread message

Ícaro Lorran

unread,
Jan 13, 2023, 11:22:42 AM1/13/23
to Google Ads API and AdWords API Forum
I want to make this query:

```
SELECT
customer.currency_code,
campaign_budget.amount_micros,
metrics.cost_micros,
segments.date
FROM campaign
WHERE
segments.date BETWEEN campaign.start_date AND campaign.end_date
```

But since the clause `BETWEEN` expects a string in the format `YYYY-MM-DD`, it yields an error related to it. What is the proper way to write the WHERE clause?

Google Ads API Forum Advisor

unread,
Jan 15, 2023, 9:39:34 PM1/15/23
to icaro...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

With regards to your concern, since the campaign.start_date and campaign.end_date are in the YYYY-MM-DD format, it is expected that when you want to put these in the WHERE clause, you will also need to put their values in the YYYY-MM-DD format.

In addition, to have a clearer understanding regarding this, I would really suggest using these query builder and query validator tools that will help and guide you as you build and validate your query.

Let us know if you have further questions.

Regards,
Google Logo
Carmela
Google Ads API Team
 


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