Skip to content

Date & Time Operators

Date operators let you compare dates, check if something is recent, and validate ages.

Check if a date is after another date:

__expiry__ of **License** is later than date(2024-01-01)

Interactive Example

Policy Rule
Test Data (JSON)

Check if a date is before another date:

__created__ of **Account** is earlier than date(2020-01-01)

Interactive Example

Policy Rule
Test Data (JSON)

Check if a date is within a duration from now:

__last_login__ of **User** is within 30 days
__test_date__ of **Driver** is within 2 years

Supported time units: seconds, minutes, hours, days, weeks, months, years, decades, centuries.

Interactive Example

Policy Rule
Test Data (JSON)

Check if a date-based age exceeds a duration. Useful for age verification:

__date_of_birth__ of **Person** is older than 18 years

Interactive Example

Policy Rule
Test Data (JSON)

The inverse of older than:

__date_of_birth__ of **Person** is younger than 65 years

Interactive Example

Policy Rule
Test Data (JSON)

All duration operators (within, older than, younger than) can compare against another date property instead of the current date by adding of followed by a property access:

<property> is <operator> <duration> of [the] <property>

Check if two dates fall within a duration of each other:

the __date__ of the **theory** in the **testDates** in the **drivingTest** is within 2 years of the __date__ of the **practical** in the **testDates** in the **drivingTest**

Interactive Example

Policy Rule
Test Data (JSON)

When the dates are too far apart, the condition fails:

Interactive Example

Policy Rule
Test Data (JSON)

Check if one date is older than a duration relative to another date:

__start_date__ of **Contract** is older than 1 year of __end_date__ of **Contract**

Check if one date is younger than a duration relative to another date:

__renewal__ of **Policy** is younger than 6 months of __expiry__ of **Policy**

All supported time units:

UnitSingularPlural
Secondsecondseconds
Minuteminuteminutes
Hourhourhours
Daydaydays
Weekweekweeks
Monthmonthmonths
Yearyearyears
Decadedecadedecades
Centurycenturycenturies