QRY_Condition.DateLiteral
Class · Group: Query Infrastructure
Learn it: Fast Start - Selectors and Selectors guide
global inherited sharing class QRY_Condition.DateLiteral implements QRY_Condition.EvaluableImplements: QRY_Condition.Evaluable
Provides SOQL date literal values for use in QRY_Builder conditions. Implements Evaluable so date literals can be passed as condition values to FieldCondition and through the QRY_Builder fluent API. Date literals are special SOQL keywords (TODAY, LAST_N_DAYS:30, etc.) that represent relative date/time ranges and cannot be expressed as bind variables.
Example
// Records created in the last 30 days
List<Account> accounts = QRY_Builder.selectFrom(Account.SObjectType)
.condition('CreatedDate').equals(new QRY_Condition.DateLiteral().lastNDays(30))
.toList();
// Records created today
List<Account> accounts = QRY_Builder.selectFrom(Account.SObjectType)
.condition('CreatedDate').equals(new QRY_Condition.DateLiteral().today())
.toList();Methods
| Method | Description |
|---|---|
| global QRY_Condition.DateLiteral last(Integer numberOfUnits, QRY_Condition.UnitOfTime unit) | Sets the date literal to LAST_N_*:n. |
| global QRY_Condition.DateLiteral last(QRY_Condition.UnitOfTime unit) | Sets the date literal to LAST_* for a given unit (e.g., LAST_QUARTER). |
| global QRY_Condition.DateLiteral last90Days() | Matches today and the 90 days before it, with the SOQL keyword LAST_90_DAYS. |
| global QRY_Condition.DateLiteral lastNDays(Integer numberOfDays) | Matches today and the n days before it, written as LAST_N_DAYS:n (lastNDays(30) writes LAST_N_DAYS:30). |
| global QRY_Condition.DateLiteral next(Integer numberOfUnits, QRY_Condition.UnitOfTime unit) | Sets the date literal to NEXT_N_*:n. |
| global QRY_Condition.DateLiteral next(QRY_Condition.UnitOfTime unit) | Sets the date literal to NEXT_* for a given unit (e.g., NEXT_QUARTER). |
| global QRY_Condition.DateLiteral next90Days() | Matches the next 90 days, starting tomorrow, with the SOQL keyword NEXT_90_DAYS. |
| global QRY_Condition.DateLiteral nextNDays(Integer numberOfDays) | Matches the next n days, starting tomorrow, written as NEXT_N_DAYS:n (nextNDays(60) writes NEXT_N_DAYS:60). |
| global QRY_Condition.DateLiteral thisUnit(QRY_Condition.UnitOfTime unit) | Matches the current week, month, quarter, year, fiscal quarter or fiscal year, written as THIS_ and the unit name, such as THIS_MONTH. |
| global QRY_Condition.DateLiteral today() | Matches the whole of today, with the SOQL keyword TODAY. |
| global QRY_Condition.DateLiteral tomorrow() | Matches the whole of the day after today, with the SOQL keyword TOMORROW. |
| global QRY_Condition.DateLiteral yesterday() | Matches the whole of the day before today, with the SOQL keyword YESTERDAY. |
last
global QRY_Condition.DateLiteral last(Integer numberOfUnits, QRY_Condition.UnitOfTime unit)Sets the date literal to LAST_N_*:n.
Parameters
| Parameter | Type | Description |
|---|---|---|
numberOfUnits | Integer | The number of units |
unit | QRY_Condition.UnitOfTime | The unit of time |
Returns QRY_Condition.DateLiteral — The DateLiteral instance for method chaining.
Example
new QRY_Condition.DateLiteral().last(4, QRY_Condition.UnitOfTime.QUARTER)global QRY_Condition.DateLiteral last(QRY_Condition.UnitOfTime unit)Sets the date literal to LAST_* for a given unit (e.g., LAST_QUARTER).
Parameters
| Parameter | Type | Description |
|---|---|---|
unit | QRY_Condition.UnitOfTime | The unit of time |
Returns QRY_Condition.DateLiteral — The DateLiteral instance for method chaining.
Example
new QRY_Condition.DateLiteral().last(QRY_Condition.UnitOfTime.QUARTER)last90Days
global QRY_Condition.DateLiteral last90Days()Matches today and the 90 days before it, with the SOQL keyword LAST_90_DAYS. lastNDays(90) writes the same keyword.
Returns QRY_Condition.DateLiteral — The DateLiteral instance for method chaining.
Example
new QRY_Condition.DateLiteral().last90Days()lastNDays
global QRY_Condition.DateLiteral lastNDays(Integer numberOfDays)Matches today and the n days before it, written as LAST_N_DAYS:n (lastNDays(30) writes LAST_N_DAYS:30). For 90 it writes LAST_90_DAYS. A negative number throws IllegalArgumentException.
Parameters
| Parameter | Type | Description |
|---|---|---|
numberOfDays | Integer | The number of days |
Returns QRY_Condition.DateLiteral — The DateLiteral instance for method chaining.
Example
new QRY_Condition.DateLiteral().lastNDays(30)next
global QRY_Condition.DateLiteral next(Integer numberOfUnits, QRY_Condition.UnitOfTime unit)Sets the date literal to NEXT_N_*:n.
Parameters
| Parameter | Type | Description |
|---|---|---|
numberOfUnits | Integer | The number of units |
unit | QRY_Condition.UnitOfTime | The unit of time |
Returns QRY_Condition.DateLiteral — The DateLiteral instance for method chaining.
Example
new QRY_Condition.DateLiteral().next(2, QRY_Condition.UnitOfTime.FISCAL_YEAR)global QRY_Condition.DateLiteral next(QRY_Condition.UnitOfTime unit)Sets the date literal to NEXT_* for a given unit (e.g., NEXT_QUARTER).
Parameters
| Parameter | Type | Description |
|---|---|---|
unit | QRY_Condition.UnitOfTime | The unit of time |
Returns QRY_Condition.DateLiteral — The DateLiteral instance for method chaining.
Example
new QRY_Condition.DateLiteral().next(QRY_Condition.UnitOfTime.QUARTER)next90Days
global QRY_Condition.DateLiteral next90Days()Matches the next 90 days, starting tomorrow, with the SOQL keyword NEXT_90_DAYS. nextNDays(90) writes the same keyword.
Returns QRY_Condition.DateLiteral — The DateLiteral instance for method chaining.
Example
new QRY_Condition.DateLiteral().next90Days()nextNDays
global QRY_Condition.DateLiteral nextNDays(Integer numberOfDays)Matches the next n days, starting tomorrow, written as NEXT_N_DAYS:n (nextNDays(60) writes NEXT_N_DAYS:60). For 90 it writes NEXT_90_DAYS. A negative number throws IllegalArgumentException.
Parameters
| Parameter | Type | Description |
|---|---|---|
numberOfDays | Integer | The number of days |
Returns QRY_Condition.DateLiteral — The DateLiteral instance for method chaining.
Example
new QRY_Condition.DateLiteral().nextNDays(60)thisUnit
global QRY_Condition.DateLiteral thisUnit(QRY_Condition.UnitOfTime unit)Matches the current week, month, quarter, year, fiscal quarter or fiscal year, written as THIS_ and the unit name, such as THIS_MONTH. DAY gives TODAY, because SOQL has no THIS_DAY. A null unit throws a NullPointerException.
Parameters
| Parameter | Type | Description |
|---|---|---|
unit | QRY_Condition.UnitOfTime | The unit of time |
Returns QRY_Condition.DateLiteral — The DateLiteral instance for method chaining.
Example
new QRY_Condition.DateLiteral().thisUnit(QRY_Condition.UnitOfTime.MONTH)
new QRY_Condition.DateLiteral().thisUnit(QRY_Condition.UnitOfTime.DAY) // returns TODAYtoday
global QRY_Condition.DateLiteral today()Matches the whole of today, with the SOQL keyword TODAY. Pass the result as a condition value, for example to equals(). It replaces any date set earlier on this object.
Returns QRY_Condition.DateLiteral — The DateLiteral instance for method chaining.
Example
new QRY_Condition.DateLiteral().today()tomorrow
global QRY_Condition.DateLiteral tomorrow()Matches the whole of the day after today, with the SOQL keyword TOMORROW. Pass the result as a condition value, for example to equals(). It replaces any date set earlier on this object.
Returns QRY_Condition.DateLiteral — The DateLiteral instance for method chaining.
Example
new QRY_Condition.DateLiteral().tomorrow()yesterday
global QRY_Condition.DateLiteral yesterday()Matches the whole of the day before today, with the SOQL keyword YESTERDAY. Pass the result as a condition value, for example to equals(). It replaces any date set earlier on this object.
Returns QRY_Condition.DateLiteral — The DateLiteral instance for method chaining.
Example
new QRY_Condition.DateLiteral().yesterday()