Say I have a query that goes something like this:
Currency_Exchange_Rates__c cerRec = [SELECT Currency_Code__c, Exchange_Rate_Period__c, Exchange_Rate__c
WHERE Currency_Code__c = :c.Currency__c
AND THIS_MONTH = CALENDAR_MONTH(Exchange_Rate_Period__c)
AND THIS_YEAR = CALENDAR_YEAR(Exchange_Rate_Period__c) LIMIT 1];
This returns an error:
expecting a colon, found 'CALENDAR_MONTH'
A little research reveals that you can't actually compare the result of a Date function with a Date literal in the WHERE clause (see Notes at bottom of this page)
So Salesforce has clearly documented that I can't do this, but I can't figure out how to work around this limitation? Seems like a pretty common use case - how can I best filter out SOQL records where I need to compare a date field to a current date?