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

Popular posts from this blog

Salesforce Spring 16 Release Exam (Maintenance Exam Q&A) for Developer 201 Admin

Show Hyper Link On Add Error in Salesforce Trigger

Show the Success Message before Redirecting the Detail page on Visualforce Page