How to get data for a certain month only?

107 views
Skip to first unread message

Bryan Yen

unread,
Jun 5, 2023, 10:54:41 PM6/5/23
to Google Ads API and AdWords API Forum
Hi,

I want to get data for a certain month only, but I seem to be stuck in getting it to work right. I'm grabbing data from the search_term_view table. Here's my query below. Any idea would be appreciated!

SELECT search_term_view.search_term, segments.search_term_match_type, customer.currency_code, metrics.clicks, metrics.ctr, metrics.average_cpc, metrics.average_cost, metrics.absolute_top_impression_percentage, metrics.top_impression_percentage, metrics.conversions, metrics.view_through_conversions, metrics.cost_per_conversion, metrics.all_conversions_from_interactions_rate

FROM search_term_view
WHERE segments.month = '2023-05-01'

With this query, I'm getting this error "Dates used in filtering conditions on 'segments.month' must occur on the first day of a month"

I tried  WHERE segments.month DURING LAST_MONTH, but I also get an error with that too

Bryan Yen

unread,
Jun 6, 2023, 6:21:15 PM6/6/23
to Google Ads API and AdWords API Forum
just in case someone else runs into this issue. I was able to get it working by using 'segments.date' instead of 'segments.month' in the WHERE clause.

--

WHERE segments.date DURING LAST_MONTH

--

Google Ads API Forum Advisor

unread,
Jun 9, 2023, 3:06:30 AM6/9/23
to bryan...@gmail.com, adwor...@googlegroups.com
Hi Bryan,

Thank you for reaching out to us and We're glad that you were able to figure out your use case. Yes, you're correct. You will need to use LAST_MONTH for your condition to get the from last month.

Please do let us know if you have any other concerns related to Google Ads API. We'll be happy to assist you.
 
This message is in relation to case "ref:_00D1U1174p._5004Q2m9kj9:ref"

Thanks,
 
Google Logo Google Ads API Team


Reply all
Reply to author
Forward
0 new messages