We are building a DMN in which we need to compare a date and time, with the current date and time.
We use FEEL. First we try with “now ()”:
We have the following error:
The process could not be started. : FEEL/SCALA-01008 Error while evaluating expression: failed to evaluate expression ‘< now()’: ValLocalDateTime(2020-01-27T21:00) can not be compared to ValDateTime(2021-04-13T15:34:02.145502600-03:00[America/Buenos_Aires])
We see that it tells us that it is a different type of data.
The only way we can find to do it is by using “date and time”:
What generates us: DMN Result: {result = 2021-04-13T00: 00: 00}
But this way we don’t have hours, minutes and seconds.
.
.
Why do “now ()” and “date and time” generate different data types?
How can we compare a date and time with the current date and time?
The process could not be started. :
FEEL/SCALA-01008 Error while evaluating expression: failed to evaluate expression ‘< now()’: ValLocalDateTime(2020-01-27T21:00) (This is startInDefaultDate) can not be compared to ValDateTime(2021-04-13T15:34:02.145502600-03:00[America/Buenos_Aires]) (This is now())
FEEL distinguish between date-time value with and without timezone.
now() returns a date-time value with timezone.
A java.util.Date is transformed into a date-time value without a timezone.
A date-time value with a timezone can’t be compared to a value without a timezone.
One solution is to store the startInDefaultDate as date-time with a timezone, for example, using the type ZonedDateTime. Or, storing the value as a string in the ISO 8601 format (e.g. 2021-04-13T15:34:02.145502600-03:00[America/Buenos_Aires]).
Another solution is to cut the timezone from now(). For example, by using the expression:
date and time(today(), time(now().hour, now().minute, now().second))