This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.

⚠️ We've moved!

Hi there!

To reduce project dependency on 3rd party paid services the StackStorm TSC has decided to move the Q/A from this forum to Github Discussions. This will make user experience better integrated with the native Github flow, as well as the questions closer to the community where they can provide answers.

Use 🔗 Github Discussions to ask your questions.

How to handle/compare time, datetime by using Jinja

Hi,

is there any possibility to handle date and time values in an orquesta workflow?
I want to compare a date and time value from JSON ( 2020-11-13T09:08:34.591Z) to the current time within Jinja.
Some methods to convert it to a datetime object and afterwards check if it is within the last 7 days for example would be helpful.

Maybe like: https://support.sendwithus.com/jinja/jinja_time/

It can be done using YAQL

Dataset
{
date: “2020-11-13T09:08:34.591Z”
}

YAQL query

let(datetime($.date.rightSplit(".",1).first(), "%Y-%m-%dT%H:%M:%S"))->[$.year, $.month, $.day, $.hour, $.minute, $.second]

Result

[
    2020,
    11,
    13,
    9,
    8,
    34
]

How you evaluate the information from there is up to you. (this solution isn’t perfect because the millisecond isn’t supported or the timezone).

Thank you very much this might help. Sometimes I forget to check yaql possibilities as well.
But in general I prefer Jinja as it offers more possibilities to use if clauses, etc.

Would be really nice to find a Jinja solution.