Write a SOQL query to fetch all Contacts whose Birthdate is in the Current Calendar Month (WHERE CALENDAR_MONTH(Birthdate) = 10).
Answer
Use the CALENDAR_MONTH() date function in the WHERE clause. In Apex, bind the current month instead of hardcoding it.
soql
SELECT Id, Name, Birthdate FROM Contact WHERE CALENDAR_MONTH(Birthdate) = 10
apex
Integer m = Date.today().month();
List<Contact> cs = [SELECT Id, Name FROM Contact WHERE CALENDAR_MONTH(Birthdate) = :m];
soqlscenariodate-functions