Get Record based on Specific Date in SOQL using IN Operator
We can use IN operator to put a filter on multiple dates while using the Day_Only function.
Get specific date of records using IN operator with Day_Only Function
List<Account> lstofacc = [SELECT Id, Name, CreatedDate FROM Account WHERE Day_Only(CreatedDate) IN (2022-01-24, 2022-01-25)];
System.debug(accList);
bind variables as well:
Date d1 = Date.parse('01/24/2022');
Date d2 = Date.parse('01/25/2022');
List<Account> accList = [SELECT Id, Name, CreatedDate FROM Account WHERE Day_Only(CreatedDate) IN (:d1, :d2)];
System.debug(accList);
Comments
Post a Comment