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)];

Comments

Popular posts from this blog

Salesforce Fact #192 | Call batch apex from flow

Salesforce Fact #457 | Get current user role name in flow