select id from Opportunity where CreatedDate < LastModifiedDate LIMIT 1;

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

1 Answer 1


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;

You must log in to answer this question.

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