What Is Data Literals In SOQL?
A date literal in SOQL is a fixed expression representing a relative time range, such as last month, this week, or next year.
Whenever we write date literals, it substitutes a value that should be there and which is dynamic.
Various Date Literal in Salesforce
- Yesterday
List<Account> accList;
accList = [SELECT Id FROM Account WHERE createdDate = Yesterday];
- Today
accList = [SELECT Id FROM Account WHERE createdDate = Today];
- Tomorrow
accList = [SELECT Id FROM Account WHERE createdDate = Tomorrow];
- Last_Week
accList = [SELECT Id FROM Account WHERE createdDate = Last_Week];
- Last_Month
accList = [SELECT Id FROM Account WHERE createdDate = Last_Month];