0

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.

3
  • Is it "Date" or "Date/time" the query needs to be written specific to the data type. – HomerJ Feb 9 '15 at 20:29
  • It is a [Date] field – Christoph Feb 9 '15 at 20:31
  • you are comparing date field to datetime. Remove the time. – cartman Feb 9 '15 at 20:34
2

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.

1
  • 1
    THanks HomerJ, that works and feeling rather silly now. Will accept and leave question in case someone else gets hung up on the same thing. – Christoph Feb 9 '15 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.