How to filtering get campaign (CampaignService) by date?

36 views
Skip to first unread message

mais trum

unread,
Jul 13, 2020, 11:43:18 PM7/13/20
to AdWords API and Google Ads API Forum
Hello

I use c# .net library for call api adwords, but when i try to get data campaign for i got all data, can i filter it by date?

this is my code for filtering by date, but i got null for result

string StartDate = "20200706";  (There are my campaign which start with this date)
string EndDate = "20200731";
selector.predicates = new Predicate[]
{
   Predicate.GreaterThanEquals(Campaign.Fields.StartDate, StartDate),
   Predicate.LessThanEquals(Campaign.Fields.EndDate, EndDate)
};

I try to use using predicate like that, because i read the documentation that say, 

GREATER_THAN_EQUALS
Checks if the field is greater or equal to the given value.
This operator is used with numbers and dates.

Can you help me?

Thanks, Regards 

Google Ads API Forum Advisor Prod

unread,
Jul 14, 2020, 10:05:44 AM7/14/20
to maist...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out. Please see here for details on setting a custom date range in your report. As it says, you have to create a date range object and set its min and max values to your start and end date. Then, you set the dat erange type to CUSTOM_DATE.

If you are using AWQL, you just need to set the DURING clause to your desired dates.

This is only applicable for reports, not for the CampaignService.

Regards,
Mitchell
Google Ads API Team

ref:_00D1U1174p._5004Q21lWKa:ref

maist...@gmail.com

unread,
Jul 14, 2020, 9:50:31 PM7/14/20
to AdWords API and Google Ads API Forum
Hi,

Thanks for the reply, but in this documentation , there is field selector startDate and endDate field in it say like this

startDate

xsd:string

Date the campaign begins. On add, defaults to the current day in the parent account's local timezone. The date's format should be YYYYMMDD.

This field can be selected using the value "StartDate".
This field can be filtered on.

This field can be filtered on, it mean i can use this for filter my data request, right?
Then, how can i filter by StartDate and EndDate?

Thanks, regards.

pratama

unread,
Jul 14, 2020, 11:50:12 PM7/14/20
to AdWords API and Google Ads API Forum
Hi,

I have solved the problem, my mistake is because i filter not a same fields,

string StartDate = "20200706";
string EndDate = "20200731";
selector.predicates = new Predicate[]
{
   Predicate.GreaterThanEquals(Campaign.Fields.StartDate, StartDate),
   Predicate.LessThanEquals(Campaign.Fields.EndDate, EndDate)  Wrong (my Campaign.Fields.EndDate = 20371230)
   Predicate.LessThanEquals(Campaign.Fields.StartDate , EndDate)  Success Filter
};

Thanks, Regards

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "AdWords API and Google Ads API Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adwords-api/GABxh4IqXt8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-api...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/57f1505f-4320-4127-80a8-71488b9f475bn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages