2

I am getting parsing error is below query:

select 
    id, name, Excercising__c, 
    opportunity__r.id, opportunity__r.Contract.Status 
from option__C 
where 
    opportunity__r.Contract.status__c='current' AND 
    Excercising__c  ='No' AND 
    ( 
        Option_to_Renew_First_Date__c =system.today()+180   OR 
        Market_Review_First_Date_Landlord__c=system.today()+180 OR 
        Excercise_Start_Date__c =system.today()+180 OR 
        Market_Review_First_Date_Tenant__c= system.today()+180
    )  

can someone please help me out of this? I am getting parsing error in code between the () as I checked after removing them and it is working as expected. Kindly help.

3
  • 1
    Isn't it just that you are missing the : in front of System.today()+180 ? – Sergio Alcocer Mar 1 at 8:12
  • 1
    ye, same and you need to wrap into :(system.today + 180), maybe a good idea to put it into a separate variable before the SOQL – ytiq Mar 1 at 8:13
  • I tried after putting : , It is still giving parsing error. I cant add the variable as I am passing this into batch class from schedulable class – Anoop Mar 1 at 8:18
3

Use a colon to specify a bind variable (as also mentioned by others in comment):

Option_to_Renew_First_Date__c = :System.today().addDays(180)

Another alternative is to use the SOQL date literals. Example:

Option_to_Renew_First_Date__c = NEXT_N_DAYS:180

Note: NEXT_N_DAYS doesn't includes TODAY

For adding today in filter, use Option_to_Renew_First_Date__c IN (NEXT_N_DAYS:180, Today)

enter image description here

2
  • @Rahul: Thanks... I updated my code to Option_to_Renew_First_Date__c = NEXT_N_DAYS:180 and it is working now. Appriciate you help :) – Anoop Mar 1 at 8:48
  • Welcome, also the NEXT_N_DAYS doesn't include today's date, see my edit if you also want today's record in filter. – Raul Mar 1 at 10:02

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.