I am trying to pass a variable into SOQL statement, I am using simple_salesforce library. I only need to grab the data when CreateDate of the Opportunity is > than yesterday, yesterday's date is saved in
last_run_day variable. Below is my code:
yesterday = date.today() + timedelta(days=-1) last_run_date = yesterday.strftime("%Y-%m-%d"+"T"+"%H:%M:%S"+"Z") sf_data = sf.query_all("SELECT ID, Name FROM Opportunity where probability > 0 AND CreatedDate > '%s' AND AdPoint_Id__c <> NULL ORDER BY AdPoint_Id__c" % last_run_date) print(sf_data)
Gives me an error: field 'CreatedDate' must be of type dateTime and should not be enclosed in quotes", 'errorCode': 'INVALID_FIELD'