[SalesForce] SOQL query to get records with start date in next 90 days

I'm trying to build a dynamic soql where a date field has to be in the next 90 days so the soql i wrote is as below , however this isn't working:

SELECT Id FROM X__c WHERE Start_Date__c = NEXT_90_DAYS.

Any help as to where I'm doing wrong?

Best Answer

It's because you're querying the objects with a date equals to the next 90 days.

Try this:

SELECT Id FROM X__c WHERE Start_Date__c <= NEXT_90_DAYS AND Start_Date__c > TODAY
Related Topic