In Salesforce, we can query records based on created or modified today or yesterday, as well as those with information related to tomorrow’s date, by appending TODAY, YESTERDAY, or TOMORROW to the WHERE clause in the SOQL query.
In this Salesforce tutorial, I will explain how to query records of standard and custom objects using date literals such as ‘today’, ‘tomorrow’, or ‘yesterday’ in Salesforce SOQL.
Query Records by Today Filter in Salesforce SOQL
To query the records created or updated on today’s date, we can execute the following SOQL query.
Query Account records created today:
For example, you have to query the account records created on today’s date, and then we can use the SOQL query below.
SELECT Id, Name, Type, Phone FROM Account WHERE CreatedDate = TODAYAfter executing the above SOQL query, the account records you created today will be returned in the query.

Query Account records last modified today:
Similarly, when you have to query the account records updated on today’s date, execute the following SOQL query.
SELECT Id, Name, Type, Phone FROM Account WHERE LastModifiedDate = TODAY
Query Account records that were deleted today:
In Salesforce, if a record is deleted, it remains in the Salesforce recycle bin for 15 days or until it is manually removed from the recycle bin. We can’t query records that were deleted today, such as those with the condition “IsDeleted = Today,” because the IsDeleted condition only accepts a boolean expression.
We can combine the IsDeleted filter with LastModifiedDate in the SOQL query to retrieve deleted records as of today’s date.
In the developer console, the query below might not work, so you can execute the query in Salesforce Workbench to query the deleted records today.
Select Id, name from Account where IsDeleted = True and LastModifiedDate = Today To execute the query in the Salesforce workbench, navigate to workbench.developerforce.com, then log in with your credentials, and in the next window, for the field “Jump to, ” select SOQL query, then choose the object to which you want to query the deleted records.
Enter the query in the query editor and ensure you have selected the radio button “Include deleted and archived records.”

This way, we can query the object records that were created, updated, and deleted on today’s date.
Query Records by Tomorrow filter in Salesforce SOQL
The common use case of the Tomorrow filter in Salesforce SOQL queries is to query events for tomorrow or any opportunity with a close date set for tomorrow.
Query Opportunity records where the Close date is tomorrow:
For example, when you need to query opportunity records with a close date of tomorrow, we can execute the SOQL query in the following manner.
SELECT Id, StageName FROM Opportunity WHERE CloseDate = TOMORROWOutput:

We can experiment with the TOMORROW filter to query custom or standard date fields, such as expiration dates or deliveries that are scheduled for tomorrow’s date.
Query Records by Yesterday filter in Salesforce SOQL
To query any information related to the object, such as the created date or modified date, we can use the ‘Yesterday’ filter in SOQL queries.
For example, to query the account records that were last modified yesterday, we can execute the following SOQL query.
SELECT Id, Name, Phone FROM Account WHERE LastModifiedDate = YESTERDAY
If you all want to query the last activities related to the accounts modified yesterday, then we can execute the SOQL query below for this polymorphic relation.
SELECT Id, (SELECT, Subject, CreatedDate FROM ActivityHistories), Name, Phone FROM Account WHERE LastModifiedDate = YESTERDAYOutput:

Combining Today, Tomorrow, and Yesterday Date Filters in Salesforce SOQL
When you apply the filter conditions that require both Today’s and Tomorrow’s filters, we can add them to the SOQL query using the AND & OR operators.
For example, you need to query the account records created today and have an event (custom date) scheduled for tomorrow; then, we can execute the following SOQL query.
SELECT Id, Name, Type, Phone FROM Account WHERE CreatedDate = TODAY AND Event_Date__c = TOMORROWOutput:

This way, we can combine the date filters using the AND operator to combine the query conditions for TODAY and TOMORROW records.
Similarly, we can also use the OR operator to combine filter conditions.
For example, you must query the account records modified today and yesterday.
SELECT Id, Name, Type, Phone FROM Account WHERE LastModifiedDate = TODAY OR LastModifiedDate = YESTERDAYOutput:

This way, we can combine data literals, such as TODAY, TOMORROW, and YESTERDAY, using AND-OR operators to define conditions in Salesforce SOQL queries.
You may also like to read:
- Query Validation Rule in Salesforce
- Query Salesforce Picklist Field values using SOQL
- Return Map Result from SOQL Query in Salesforce Apex
- Query to Count Child Records in Salesforce SOQL
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.