How to compare these two dates using FEEL

Date1: 2023/04/23

Date2: 04-23-2023

How to compare these two dates using FEEL.

We got some reference using FEEL however that is manual expression.

What is recommended approach to compare above 2 dates.

Reference:

The first step would be to normalize both of those dates. They could be Apr 23, 2023, or they could be invalid.

If you know 100% that date 1 will ALWAYS be YYYY/mm/dd, then you can make it a date with the date function

For example, you could use the following to confirm that date1 and date2 are the same date:

date(number(substring(date1,1,4)),number(substring(date1,6,2)),number(substring(date1,9,2))) =
date(number(substring(date2,7,4)),number(substring(date2,1,2)),number(substring(date2,4,2)))

Try it out on the Playground

@Raj_Kishun_Singh - as mentioned in the previous reply, the best solution is to normalize the date format that is coming into Camunda. Otherwise, you’ll need to know what format the dates are in for each variable in order to parse it.

There’s a few solutions:

  1. @GotnOGuts solution above
  2. Here’s another way to do it by splitting the strings: FEEL Playground example
  3. Here’s another way that uses regular expressions: FEEL Playground example
  4. Call a job worker (or create a connector) to normalize the dates so you can utilize the native FEEL functionality.

If you could also provide feedback on this issue, it will help the product team prioritize it: functions to parse date, time and datetime with given schema · Issue #798 · camunda/feel-scala · GitHub

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