5

I am using the Salesforce API through R. I am querying an object and I want to return results only if a date field "Begin_Date__c" is in a particular month specified by the user. Now if I only want values in a particular month, I am able to accomplish this by using
CALENDAR_MONTH(Begin_Date__c) = desired_month inside the WHERE clause
But I do not know how to do the same thing if I want say all records in a range of months (5, 6, 7, 8, 9 or the summer months). How do I change the query so as to check against a vector of month values instead of just one?

10

You can use the IN operator:

SELECT ... FROM ... WHERE CALENDAR_MONTH(field) IN (5,6,7,8,9)

Or as a range:

SELECT ... FROM ... WHERE CALENDAR_MONTH(field) >= 5 AND CALENDAR_MONTH(field) <= 9
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.