Koch
November 21, 2023, 3:32pm
1
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.
${ bp_date_test < “2021-04-13” } ← Test is not evaluated correctly
${ 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 ‘}’.
${ bp_date_test < date(“2021-04-13”) } ← ENGINE-01009 Error while parsing process. Could not resolve function ‘date’.
${ 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
Welcome to the Camunda Community!
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
Koch
November 22, 2023, 10:07am
3
Hey,
thank you for your reply. Now I tried to use the following conditionExpressions:
<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.
<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
hassang
November 22, 2023, 8:05pm
6
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
Koch
November 29, 2023, 2:42pm
7
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.
system
Closed
December 6, 2023, 2:42pm
8
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.