7

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?

1 Answer 1

13

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .