SELECT Id, Last_stage_changed_date__c, CreatedDate
FROM Opportunity
WHERE Last_stage_changed_date__c < CreatedDate
Last_stage_changed_date__c
is of the Date
type. I feel like I'm doing something dumb but I can't spot it.
Getting the error:
Bind variables only allowed in Apex code
Best Answer
You cannot compare one field to another in SOQL, regardless of context. If you want to compare a custom date field to
CreatedDate
, you will need a separate checkbox formula field to do the comparison for you, then you can filter on this field being true.Take a look at the documentation on fieldExpression Syntax (emphasis mine):