New to SOQL and using python to script SF object pulls. I am pulling from Case and need just when Case_Created__c > 2020-12-31, but am getting a error with the DateTime format issue.

For other objects like Opportunity, I do not have this issue when filtering on Created_Date__c.

Would be very appreciative if someone on here who knows why I am getting errors for one and not the other can explain what is going on.

Here is the code of my SF query:

query_line = sf.query_all('SELECT CaseNumber, AccountId, RecordTypeId, Status, Subject,
Description, OwnerId, CreatedById, Record_Type__c, Account_Channel__c, Account_Num__c,
AC_Manager__c, Account_Region__c,
Account_Sales_Office__c, Type_of_Work__c, Opportunity__c, Owner_Manager_Name__c, 
Requested_Due_Date__c, Created_By_Channel__c, Opportunity_ID__c, Opportunity_Name__c, 
Opportunity_MRC__c, Opportunity_NRC__c, ImpartnerPRM__PartnerAccount__c, Product__c,
Sales_Engineer__c, Post_SE_Support_Type__c, Case_Created__c, Account_Segment__c, 
Account_Vertical__c, OpportunityID__c, 
Action_Taken__c, Partner_Account_Name__c, Opportunity_Stage__c, Hours_Worked__c,
Systems_Used__c, CS_Owner__c, Task_Origin__c, Customer_Success__c 
FROM Case WHERE Case_Created__c > 2020-12-31')

and here is the error message:

Response content:

[{'message': "\nCustomer_Success__c FROM Case WHERE Case_Created__c > 2020-12-31\n ^\nERROR at Row:1:Column:718\nvalue of filter criterion for field 'Case_Created__c' must be of type dateTime and should not be enclosed in quotes", 'errorCode': 'INVALID_FIELD'}]


1 Answer 1


As per error message description, case custom field Case_Created__c is of type DateTime so where condition must be formatted as YYYY-MM-DDThh:mm:ssZ (optional timezone)

SELECT CaseNumber, AccountId, ...
FROM Case 
WHERE Case_Created__c > 2020-12-31T00:00:00Z

More info in documentation

For Opportunity, it probably worked fine because custom field Created_Date__c is of type Date not DateTime.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .