Unfortunately we are not allowed to pass Date values in where clause of pure SOQL (if we don’t call it from code but from Query Editor or during querying schema). SOQL constants like THIS_DAY, THIS_WEEK, LAST_WEEK do not cover all the date constants we could be interested in. So, what solution can we find?
Assume we have custom SObject Custom_Object__c with date field Custom_Date_Field__c.
Then if we need to run pure SOQL query to retrieve all records having in field Custom_Date_Field__c given date constant, let’s say 25 July of 1987, we could run following query:
SELECT Id FROM Custom_Object__c WHERE CALENDAR_YEAR( Custom_Date_Field__c ) = 1987 AND CALENDAR_MONTH( Custom_Date_Field__c ) = 7 AND DAY_IN_MONTH( Custom_Date_Field__c ) = 25.
Hope you liked this.