Date operators

Description of date operators used in decision tables

In each condition cell of a decision table, you have the flexibility to apply a variety of operators depending on your needs. These operators enable you to compare and manipulate date and time values effectively, ensuring that your conditions are evaluated accurately. You can choose from a range of operators, whether for simple equality checks or more complex comparisons involving date ranges. The full list of available operators can be found in the operators modal:

Date Cell Values

When working with date operators in decision tables, using the correct format is crucial for ensuring accurate comparisons. Each condition cell can have a distinct operator for handling dates, but it’s important to understand how dates function within DecisionRules and how to correctly enter values into the cell.

You have two ways to input the date:

  1. Manually entering the date directly into the cell (recommended)

  2. Using the date picker

Let’s explore both methods.

Writing the Date Directly into the Cell

You can now enter the date directly into the cell (this was previously only possible using the date picker). After selecting the desired date operator, click the cell, which is now set to accept date input with enhanced functionality. When you start typing, a hint will appear displaying the recommended date format:

YYYY-MM-DD HH:MM:ss Z // year-month-day hours:minutes:seconds GMT

We highly recommend always including the timezone (GMT) for accurate date interpretation.

The cell will also show how your date is interpreted in real-time through a whisper. For example, if you enter 2024-09-24 09:24 +02:00, the whisper will display the interpreted date as "September 24, 2024, at 9:24:00 AM GMT+2." This allows you to ensure that the date you’ve entered is correct.

Date Cell Validation

Date cells provide validation feedback, alerting you to any issues with date interpretation. There are two primary validation messages:

  • Invalid Date This message indicates that the input value is not recognized as a valid date. The operator will not be able to process the value, and you will need to correct it.

  • Date Doesn't Fit Format This message means the input does not follow the recommended format (e.g., using slashes like 2024/09/24 or omitting the timezone), however, the system can still interpret the date. The whisper will show how the date is interpreted.

We strongly advise sticking to the suggested format to ensure full functionality of the date operators.

Picking the Date Using the Date Picker

If you prefer to select the date visually, the date picker functionality is still available. To use the date picker, hover over the date cell, and a calendar icon will appear at the end of the cell:

Clicking the icon will open a modal where you can choose the date. By default, both the date and time are set to None, and the timezone is pre-set to GMT. You can adjust these settings if needed. Click the desired field, choose the Select Date or Select Time option, and either enter the date and time manually or click the next calendar icon:

After choosing the date, click the Submit button and save the changes by pressing Save.

The selected date will be set in the date cell in the recommended format, just as if you had entered it manually.

Deleting the Date in the Date Select Modal

If you change your mind while setting the date or time in the modal, you can unselect the Select Date or Select Time option to clear the value. Alternatively, you can delete the value directly in the date cell.

Special Case — Variables

In DecisionRules, you are not limited to explicitly setting a date in the date cell. Like other cells, date cells also support variables, such as:

For more information on variables, refer to the Table Designer: Special Case — Variable Values section

To use a variable, start typing the "{" symbol in the date cell, and a dropdown list of available variables will appear. When a variable is used in a date cell, the Dynamic Date warning will be visible in the active date cell:

Please note that date cells cannot validate the date passed through a variable. Ensure the date provided in the variable has the correct format.

Date Format

Dates are now saved as strings. To match a condition like 2024-09-24 09:27 +02:00, the request must contain the same string format: "2024-09-24 09:27 +02:00". Additionally, we support the Extended ISO8601 Date format, so the condition will also match the string "2024-09-24T09:27:00+02:00".

The old object format is deprecated but still supported. This means you can still pass a request using the old format, like so:

"date": "2024-09-24",
"time": "09:27",
"timezone": "+02:00"

This will still match the 2024-09-24 09:27 +02:00 condition.

Date Operators

The equals (=) operator compares the request date and time value with the table date value, including the time zone.

// [request value] = [table value]

"2024-09-24 09:27 +02:00" = "2024-09-24 09:27 +02:00"  // true
"2024-09-24 +02:00"       = "+02:00"                   // true

"2024-09-24 09:27 +02:00" = "2024-09-24 +02:00"        // false
"2024-09-24 09:27 +02:00" = "2024-09-24 13:27 +02:00"  // false

The not equal (!=) operator returns true if the request date string and the table date string differ in any way.

// [request value] != [table value]

"2024-09-24 09:27 +02:00" != "2024-09-24 +02:00"         // true 
"2024-09-24 09:27 +02:00" != "09:27 +02:00"              // true
"2024-09-24 09:27 +02:00" != "+02:00"                    // true

"2024-09-24 09:27 +02:00" != "2024-09-24 09:27 +02:00"   // false
"2024-09-24 +02:00"       != "+02:00"                    // false

The greater than (>) operator checks if the request date string is later than the table date string.

// [request value] > [table value]

"2024-09-24 09:27 +02:00" > "2024-09-23 09:27 +02:00"  // true
"2024-09-24 09:27 +02:00" > "2024-09-24 +02:00"        // true

// assuming "2024-09-24" is in the future:
"2024-09-24 09:27 +02:00" > "09:27 +02:00"             // true
"2024-09-24 09:27 +02:00" > "+02:00"                   // true

// assuming "2024-09-24" is in the past:
"2024-09-24 09:27 +02:00" > "09:27 +02:00"             // false
"2024-09-24 09:27 +02:00" > "+02:00"                   // false

"2024-09-24 09:27 +02:00" > "2024-09-24 09:27 +02:00"  // false
"2024-09-24 09:27 +02:00" > "2024-09-25 09:27 +02:00"  // false

The less than (<) operator returns true if the request date string is earlier than the table date string.

// [request value] < [table value]

"2024-09-24 09:27 +02:00" < "2024-09-25 09:27 +02:00"  // true
"2024-09-24 09:27 +02:00" < "2024-09-25 +02:00"        // true

// assuming "2024-09-24" is in the past:
"2024-09-24 09:27 +02:00" < "09:27 +02:00"             // true
"2024-09-24 09:27 +02:00" < "+02:00"                   // true

// assuming "2024-09-24" is in the future or today:
"2024-09-24 09:27 +02:00" < "09:27 +02:00"             // false
"2024-09-24 09:27 +02:00" < "+02:00"                   // false

"2024-09-24 09:27 +02:00" < "2024-09-24 09:27 +02:00"  // false
"2024-09-24 09:27 +02:00" < "2024-09-23 09:27 +02:00"  // false

The greater than or equal (>=) operator checks if the request date string is either later than or exactly the same as the table date string.

// [request value] >= [table value]

"2024-09-24 09:27 +02:00" >= "2024-09-24 09:27 +02:00"  // true
"2024-09-24 09:27 +02:00" >= "2024-09-23 09:27 +02:00"  // true
"2024-09-24 09:27 +02:00" >= "2024-09-24 +02:00"        // true

// assuming "2024-09-24" is in the future or today:
"2024-09-24 09:27 +02:00" >= "09:27 +02:00"             // true
"2024-09-24 09:27 +02:00" >= "+02:00"                   // true

// assuming "2024-09-24" is in the past:
"2024-09-24 09:27 +02:00" >= "09:27 +02:00"             // false
"2024-09-24 09:27 +02:00" >= "+02:00"                   // false

"2024-09-24 09:27 +02:00" >= "2024-09-25 09:27 +02:00"  // false

The less than or equal (<=) operator returns true if the request date string is earlier than or exactly the same as the table date string.

// [request value] <= [table value]

"2024-09-24 09:27 +02:00" <= "2024-09-24 09:27 +02:00"  // true
"2024-09-24 09:27 +02:00" <= "2024-09-25 09:27 +02:00"  // true
"2024-09-24 09:27 +02:00" <= "2024-09-25 +02:00"        // true

// assuming "2024-09-24" is in the past:
"2024-09-24 09:27 +02:00" <= "09:27 +02:00"             // true
"2024-09-24 09:27 +02:00" <= "+02:00"                   // true

// assuming "2024-09-24" is in the future:
"2024-09-24 09:27 +02:00" <= "09:27 +02:00"             // false
"2024-09-24 09:27 +02:00" <= "+02:00"                   // false

"2024-09-24 09:27 +02:00" <= "2024-09-23 09:27 +02:00"  // false

The between (BTW) operator checks if the request date string falls within the range of two table date strings, inclusive of both the start and the end values.

// [request value] BTW [table value 1 AND table value 2]

"2024-09-24 09:27 +02:00" BTW "2024-09-24 09:27 +02:00" AND "2024-09-25 09:27 +02:00"  // true
"2024-09-24 09:27 +02:00" BTW "2024-09-23 09:27 +02:00" AND "2024-09-24 09:27 +02:00"  // true
"2024-09-24 09:27 +02:00" BTW "2024-09-24 +02:00"       AND "2024-09-27 +02:00"        // true
"2024-09-24 09:27 +02:00" BTW "2024-09-23 +02:00"       AND "2024-09-24 09:27 +02:00"  // true
"2024-09-24 +02:00"       BTW "2024-09-23 09:27 +02:00" AND "2024-09-25 09:27 +02:00"  // true

"2024-09-24 09:27 +02:00" BTW "2024-09-28 09:27 +02:00" AND "2024-09-29 09:27 +02:00"  // false
"2024-09-24 +02:00"       BTW "2024-09-24 09:27 +02:00" AND "2024-09-25 09:27 +02:00"  // false

// assuming "2024-09-24" is in the future:
"2024-09-24 09:27 +02:00" BTW "2024-09-23 09:27 +02:00" AND "10:27 +02:00"             // false

// assuming "2024-09-24" is today or in the past:
"2024-09-24 09:27 +02:00" BTW "2024-09-23 09:27 +02:00" AND "10:27 +02:00"             // true

The not between (!BTW) operator checks if the request date string falls outside the range of two table date strings, returning true if the value is not within the range.

// [request value] !BTW [table value 1 AND table value 2]

"2024-09-24 09:27 +02:00" !BTW "2024-09-28 09:27 +02:00" AND "2024-09-29 09:27 +02:00"  // true
"2024-09-24 +02:00"       !BTW "2024-09-24 09:27 +02:00" AND "2024-09-25 09:27 +02:00"  // true

"2024-09-24 09:27 +02:00" !BTW "2024-09-24 09:27 +02:00" AND "2024-09-25 09:27 +02:00"  // false
"2024-09-24 09:27 +02:00" !BTW "2024-09-23 09:27 +02:00" AND "2024-09-25 09:27 +02:00"  // false
"2024-09-24 09:27 +02:00" !BTW "2024-09-24 +02:00"       AND "2024-09-27 +02:00"        // false
"2024-09-24 09:27 +02:00" !BTW "2024-09-23 +02:00"       AND "2024-09-24 09:27 +02:00"  // false
"2024-09-24 +02:00"       !BTW "2024-09-23 09:27 +02:00" AND "2024-09-25 09:27 +02:00"  // false

// assuming "2024-09-24" is in the future:
"2024-09-24 09:27 +02:00" !BTW "2024-09-23 09:27 +02:00" AND "10:27 +02:00"             // true

// assuming "2024-09-24" is in the past or today:
"2024-09-24 09:27 +02:00" !BTW "2024-09-23 09:27 +02:00" AND "10:27 +02:00"             // false

Last updated