# What are SOQL Date Literals (e.g., TODAY, LAST_N_DAYS:30, THIS_FISCAL_YEAR, NEXT_MONTH) and why are they preferred over hardcoded dates?

**Topic:** Soql · **Difficulty:** Easy · **Asked at:** Accenture, Capgemini, HCL · **Tags:** soql, date-literals

Read it on the site: https://www.forcechallenges.com/interview-questions/what-are-soql-date-literals-e-g-today-last-n-days-30-this-fiscal-year-next-month-and-why-are-they-preferred

## Answer

Date literals are keywords that represent relative date ranges computed at run time, e.g. `TODAY`, `YESTERDAY`, `LAST_N_DAYS:30`, `THIS_MONTH`, `NEXT_MONTH`, `THIS_FISCAL_YEAR`, `LAST_QUARTER`.

They are preferred because queries stay valid over time without code changes, respect the user's time zone and the org's fiscal year settings, and avoid date-formatting mistakes.

```soql
SELECT Id FROM Opportunity WHERE CloseDate = THIS_FISCAL_QUARTER
SELECT Id FROM Case WHERE CreatedDate = LAST_N_DAYS:30
```

---
Source: ForceChallenges · last updated 2026-10-21
