Compare date value in expression to specific value

Hi, I would like to compare a date variable in an expression (Exclusive Gateway → Condition) to a specific Date.
I already tried a couple of variants.

  1. ${ bp_date_test < “2021-04-13” } ← Test is not evaluated correctly
  2. ${ bp_date_test < 2021-04-13T00:00:00 } ← Error on save: ENGINE-01009 Error while parsing process. Error parsing ‘${ bp_date_test < 2021-04-13T00:00:00 }’: syntax error at position 28, encountered ‘T00’, expected ‘}’.
  3. ${ bp_date_test < date(“2021-04-13”) } ← ENGINE-01009 Error while parsing process. Could not resolve function ‘date’.
  4. ${ bp_date_test < @“2021-04-13” } ← ENGINE-01009 Error while parsing process. Error parsing ‘${ bp_date_test < @“2021-04-13” }’: lexical error at position 18, encountered invalid character ‘@’, expected expression token.

What would be the correct syntax to do this test?

Hey @Koch :wave:
Welcome to the Camunda Community! :partying_face:

Here is a snippet from the docs:

The REST API uses the default date format yyyy-MM-dd’T’HH:mm:ss. SSSZ , which represents a date with milliseconds and timezone information, e.g., 2016-01-25T13:33:42.165+0100

Check it out here:
Date Format | docs.camunda.org.

Best,
Thomas

Hey,

thank you for your reply. Now I tried to use the following conditionExpressions:

  1. <bpmn:conditionExpression xsi:type=“bpmn:tFormalExpression”>${ bp_date_test < “2024-01-25T13:33:42.165+0100” }</bpmn:conditionExpression>

This test is not evaluated correctly during process runtime.

  1. <bpmn:conditionExpression xsi:type=“bpmn:tFormalExpression”>${ bp_date_test < 2024-01-25T13:33:42.165+0100 }</bpmn:conditionExpression>

Error on save: Error creating bpmn process definition: ENGINE-01009 Error while parsing process. Error parsing ‘${ bp_date_test < 2024-01-25T13:33:42.165+0100 }’: syntax error at position 28, encountered ‘T13’, expected ‘}’.

bp_date_ test is a date of value 2023-04-12 during process runtime.

As far as I can tell the timestamp you have added is not being recognised as a date/time object. Hence the comparison fails.
So before comparing you would need to cast it accordingly.

Maybe this page in the docs helps:

Hi @Koch,

looking at the JUEL spec here: Jakarta Expression Language, it seems that dates are not explicitly supported by this language.

Maybe you have to get the timestamps of the values to compare them.

Hope this helps, Ingo

1 Like

Hi @Koch,

You can use feel language

Use the below script to compare the date parts only (var1 is the Date variable and “2024-01-25” is the value to compare with)
date(var1) <= date("2024-01-25")

Kindly find attached a working example
test_compare_dates.bpmn (4.5 KB)

2 Likes

It looks like it is not possible to do what I wanted within an expression then. That is also fine. Thank you for your efforts everyone.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.