0

Trying to execute next query.

Select OPPORTUNITYID__C, OM_R1_Consulting_Start_Date__c, OM_R1_Consulting_End_Date__c 
FROM Opportunity 
Where OM_R1_Consulting_Start_Date__c > OM_R1_Consulting_End_Date__c

And getting error meassege : unknown error parsing ... as result What's wrong in my query?

Both are of Date type custom field.of type: '12/17/2015'

  • query is looking fine, post the screen shot from developer console so that we can get some additional detail. you might have typo – Himanshu Jan 8 '16 at 20:16
4

SOQL does not allow comparison operators between fields, your query:

Select OPPORTUNITYID__C, OM_R1_Consulting_Start_Date__c, OM_R1_Consulting_End_Date__c 
FROM Opportunity 
Where OM_R1_Consulting_Start_Date__c > OM_R1_Consulting_End_Date__c

This expression is not allowed (unlike in some other database query languages):

Where OM_R1_Consulting_Start_Date__c > OM_R1_Consulting_End_Date__c

The general solution to this is to add a formula field in your object like this;

hasInvalidStartDate__c type = Boolean with whatever conditions make the startDate invalid

and then query where clause is

Where hasInvalidStartDate__c = true

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.