1

select id from Opportunity where CreatedDate < LastModifiedDate LIMIT 1;

Why there is parsing error when we compare CreatedDate and LastModifiedDate?

1 Answer 1

5

Salesforce does not allow direct field to field comparison in SOQL query. Workaround for this is mentioned here

In your case, add new formula checkbox field called CreatedLessThenModified__c on Opportunity:

CreatedDate < LastModifiedDate

then the following soql will work:

select id
from Opportunity
where CreatedLessThenModified__c = true
limit 1;
3

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.