Before test

Learn how to check if a date time is before another.

This test checks whether a date or instant is before another. It is the opposite of the after test.

When comparing dates, this test first converts both values to an instant based on the time zone set at the application level. Then it compares the instants using the same rules as relational operators to ensure consistency with the less than operation.

For more information about how dates are converted to instants, see the section on Date-time conversion.

Croct's mascot neutral
How does it differ from the less-than test?

This test converts its arguments to instants before comparing them, while the less than test simply fails if the arguments are incompatible.

Syntax

This test has the following syntax:

/*<value>*/ before /*<instant>*/
Try in Playground

To negate the test, you can write:

/*<value>*/ is not before /*<instant>*/
Try in Playground

Parameters

These are the supported parameters:

value

The date time to compare with the reference value.

reference

The date time to compare against.

Examples

Here is a basic example of how to compare two dates:

yesterday is before "2025-05-08" // true
Try in Playground

You can use any valid ISO 8601 date-time string as an argument.