You need to sign in to do that
Don't have an account?
Pooja Arora
SOQL Query Question
Hello,
I have just started learning SOQL and Apex programming concepts. I need some help with retrieving results using SOQL query.
The requirement is: to get all the records where Planning date__c is less than 14 days.
Any help is appreciated.
Thank you.
I have just started learning SOQL and Apex programming concepts. I need some help with retrieving results using SOQL query.
The requirement is: to get all the records where Planning date__c is less than 14 days.
Any help is appreciated.
Thank you.
The first form is incorrect, you would do "SpecificDate__c >= :Date.Today().addDays(-14) AND SpecificDate__c <= TODAY"; without the second condition, you'd be querying from 14 days ago to all future dates.
The second form is also incorrect, you would want to do "SpecificDate__c = LAST_N_DAYS:14". Don't let the "=" sign fool you, LAST_N_DAYS:X is a date range, not just a single date. Using ">=" would select all days from 14 days ago through all eternity in the future, which is probably not your intent.
IF it helps, mark it as the best answer.
Regards,
Navin S
Try this :
Select * from Account where WHERE date__c = LAST_N_DAYS:14
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
Option 1 :
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_dateformats.htm
Option 2 :
Thank you all for taking time to respond to my question.