Use Greater than in where clause using AWQL

120 views
Skip to first unread message

Leon Pidgeon

unread,
Apr 26, 2018, 10:19:57 AM4/26/18
to AdWords API and Google Ads API Forum
We are running a query using AWQL with the FeedItemService but want to filter the results by EndTime. 
Previously using the old googleads-php-lib we were able to do it like this

$awql = 'SELECT KeywordText,TargetingAdGroupId,TargetingCampaignId,FeedItemId, FeedId, Status, AttributeValues, 
EndTime
WHERE Status IN[ENABLED] AND EndTime > ' . date('Ymd', strtotime(' -1 day'));

We have updated to the new version and now our code is

$query = (new ServiceQueryBuilder())
->select([
'KeywordTargetingText',
'TargetingAdGroupId',
'TargetingCampaignId',
'FeedItemId',
'FeedId',
'Status',
'AttributeValues',
'EndTime'
])
->where('Status')->in(['ENABLED'])
->where('EndTime')->greater_than([date('Ymd', strtotime(' -1 day'))])
->build();

The greater than syntax does not work so how can we perform this same action?

Dhanya Sundararaju (AdWords API Team)

unread,
Apr 26, 2018, 3:00:39 PM4/26/18
to AdWords API and Google Ads API Forum
Hi Leon,

Could you let me know what was your previous version? You will need to pull up the date that you need, say for example . date('Ymd', strtotime(' -1 day')), format it and then use ->equalTo() to filter. For example the SOAP request would look like as below:

<query>SELECT EndDate, Id, Name, Status WHERE EndDate = "20180426" AND Name = "Interplanetary Cruise banner #2392a7d4-6000-42dc-b15a-1de84a3" LIMIT 0,100</query>

Please give it a try let me know if you have any further questions.

Regards,
Dhanya, AdWords API Team

Leon AI

unread,
Apr 27, 2018, 4:02:46 AM4/27/18
to AdWords API and Google Ads API Forum
Equal to is no good. The end date can be in the future so it could be in 1 months time so I want to find any feeditems that have an end date today or anytime in the future. I want to use greater than and I was hoping to get the syntax to use the ServiceQueryBuilder.

When I say the previous version I was using the deprectaed googleads-php-lib (https://github.com/googleads/googleads-php-lib/tree/deprecated).

Dhanya Sundararaju (AdWords API Team)

unread,
Apr 27, 2018, 12:35:13 PM4/27/18
to AdWords API and Google Ads API Forum
Hi Leon,

I am afraid, in that case, you would need to logically handle that in your code. Also, If you consider using the Placeholder Feed Item Report, with the attribute endTime, you would need to handle it on the output that you receive. Please let me know if you have any further questions.
Reply all
Reply to author
Forward
0 new messages