function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AnonTestQuestAnonTestQuest 

Help with: WHERE Today() <= Expiration_Date__c - 2

I need to have this as my where clause in a SOQL query in Sublime so I only pull records within two days of their expiration date. The custom formula field (expiration date) is a date and the Today() is a system function so it's obviously a datetime and this gives me parsing errors in dev console query editor. Also, what would I put to take 2 days off the expiration date? Would the - 2 work?
Best Answer chosen by AnonTestQuest
Amit Chaudhary 8Amit Chaudhary 8
Please try below 
WHERE Expiration_Date__c > NEXT_N_DAYS:2

Please check below post. I hope that will help you:-
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_dateformats.htm

Please let us know if that will help you

All Answers

Robert ZentgrafRobert Zentgraf
Hi,

what is the error in the dev console query editor?
Perhaps you can create a new formua field with your formular and as result you receive true or false. This can be part of your where-statement.

Regards
Robert
(mindforce: http://www.mind-force.de) (http://www.mind-force.de)
AnonTestQuestAnonTestQuest
It was just a parsing error
Amit Chaudhary 8Amit Chaudhary 8
Please try below 
WHERE Expiration_Date__c > NEXT_N_DAYS:2

Please check below post. I hope that will help you:-
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_dateformats.htm

Please let us know if that will help you
This was selected as the best answer
AnonTestQuestAnonTestQuest
AHAH! THAT'S IT! I've been racking my brain trying to figure this out. Your solution works perfectly! Thank you!
AnonTestQuestAnonTestQuest
I wrote the operator as <= though so it will keep sending the email past the expiration date if the user hasn't done what they're supposed to in order to turn the batch off for their instance.