[SalesForce] Date range on custom date field in SOQL Query

Is there a limitation that prevent filtering SOQL queries on custom date fields?

This query works;

SELECT Id FROM SomeObject__c WHERE CreatedDate >= 2012-12-27T00:00:00Z

This one;

SELECT Id FROM SomeObject__c WHERE CustomDate__c >= 2012-12-27T00:00:00Z

Returns the error

value of filter criterion for field 'CustomDate__c ' must be of
type date and should not be enclosed in quotes.

…I've double check that CustomDate__c is a date field.

Best Answer

Try this:

SELECT Id FROM SomeObject__c WHERE CustomDate__c >= 2012-12-27

and see if it works. If so, the Custom_Date__c field is Date, not Date/Time, and requires a different where statement to resolve.

Related Topic