Salesforce Fact #719 | DAY_ONLY() to get records within two dates
Suppose we need to fetch a list of records between two dates and also needs to skip for 2 days within the range. The filter field is of datetime type.
We can make use of the DAY_ONLY() function for this.
In this example, we are fetching account records created between 2023-07-01 and 2023-07-16 and skip the records created on 2023-07-06, 2023-07-07.
SOQL: SELECT Id, Name, CreatedDate FROM Account WHERE DAY_ONLY(CREATEDDATE) >= 2023-07-01 AND DAY_ONLY(CREATEDDATE) <= 2023-07-16 AND DAY_ONLY(CREATEDDATE) NOT IN (2023-07-06, 2023-07-07)
Comments
Post a Comment