cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Compare two datetime values

0 Likes
1,257

Hello everyone,

I have a scenario where I need to compare (two datetime entity values) | (datetime entity with api response date), is it currently possible? Maybe there are helpers like for date formating https://help.sap.com/viewer/a4522a393d2b4643812b7caadfe90c18/latest/en-US/b4f08a9a66434327a405b69348... ?

Thank you!

Best Regards,

Artem

Accepted Solutions (1)

Accepted Solutions (1)

JonasB
Advisor
Advisor

Hi Artem,

another option would be to use the "formatDate" helper to convert the dates to a unix millisecond timestamp and then compare those numeric values with the greater than or lower than helpers:

{{#gt (formatDate "01-31-2020" "x") (formatDate "01-30-2020" "x") }}
...
{{/gt}}

Regards
Jonas

JonasB
Advisor
Advisor
0 Likes

By the way: To get the current timestamp, you can use the formatDate helper without providing a date. So if I understand your requirement correctly, it would look like this

{{#gt (formatDate memory.myDateVar "x") (formatDate "x") }}
...
{{/gt}}
0 Likes

Hi Jonas,

It is what I need! Thank you!

Best Regards,

Artem

Answers (1)

Answers (1)

alichtenau
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Artem,

what would you like to compare? Which date is older, which date is "younger"?

Best regards,
Andreas

0 Likes

Hi Andreas,

Yes, that is right. The complete scenario is the following:

  1. I am getting the response from api with date field.
  2. I need to compare (younger, older) it with a current datetime. Current datettime I am getting from {{message_received_at}}

Thanks!

Best Regards,

Artem