Posts

Showing posts with the label IN

Salesforce Fact #651 | IN operator with Day_Only()

We can use IN operator to put filter on multiple dates while using Day_Only function. For example, the below SOQL returns the accounts which were created on 27th and 28th Jan of 2023. SELECT Id, Name, CreatedDate FROM Account WHERE Day_Only(CreatedDate) IN (2023-01-27, 2023-01-28) The same works perfectly with bind variables as well: Date d1 = Date.parse('01/27/2023'); Date d2 = Date.parse('01/28/2023'); List<Account> accList = [SELECT Id, Name, CreatedDate FROM Account WHERE Day_Only(CreatedDate) IN (:d1, :d2)];