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
vnmchatvnmchat 

How to bulkify a in-between SOQL clause

I have the following in a helper class accessed by a Trigger that is run for every Opty given we are using custom Fiscal settings:

String fiscalYear = [SELECT PeriodId, Name from FiscalYearSettings where StartDate<=:curDateEval and EndDate>=:curDateEval].Name;

 

Which I would like to convert into something like:

List<Date> datesToInclude = new List<Date>();

List<...> fiscalYrs = [SELECT Name from FiscalYearSettings where StartDate<=: IN datesToInclude and EndDate>=: IN datesToInclude]

 

Adding the "IN" keyword for a in-between date comparison is not working...does someone know how to do this Query in one shot for all my Opty dates?

 

 

aj2taylo2aj2taylo2

Could you not just get the minimum and maximum dates, and update the query to something like: 

 

List<...> fiscalYrs = [SELECT Name from FiscalYearSettings where StartDate<=: minStartDate and EndDate>=: maxStartDate]