Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I want to query on the task for multiple dates eg,

date d3 = system.today().addDays(3);
Select Id, Subject, WhoID, ActivityDate, OwnerId 
     from Task 
     where IsClosed = False and ActivityDate = :d3 
           and Subject ='Follow up Opportunity' 
     order By ActivityDate ASC;

This above code works fine now i would expand this to query for

date d7 = system.today().addDays(7);
date d15 = system.today().addDays(15);

Now how will i change this soql for all the dates matching,d3,d7,d15. Please help

share|improve this question

1 Answer 1

up vote 5 down vote accepted

Simply use an OR:

Select Id, Subject, WhoID, ActivityDate, OwnerId from Task where IsClosed = False 
        and (ActivityDate = :d3 Or ActivityDate = :d7 Or ActivityDate = :d15) 
        and Subject ='Follow up Opportunity' order By ActivityDate ASC;
share|improve this answer
2  
Or you can use IN operator. –  sfdcfox Aug 14 at 16:53
    
Can anyone give me sample for IN, i get a error with IN. I tried -Select Id, Subject, WhoID, ActivityDate, OwnerId from Task where IsClosed = False and (ActivityDate IN :d3,:d7) and Subject ='Follow up Opportunity' order By ActivityDate ASC]; Thanks Phil that works. –  user8132 Aug 14 at 18:49
    
GOT IT! select Id, Subject, WhoID, ActivityDate, OwnerId from Task where IsClosed = False and ActivityDate IN (:d3, :d7) and Subject ='Follow up Opportunity' order By ActivityDate ASC –  user8132 Aug 14 at 18:59
    
Yes, IN is less typing as you've managed to work out :) –  Phil Hawthorn Aug 14 at 19:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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