How to create a rule to check if the time is within range

I need some help to create an expression rule to check if my given time is within the range. For example, my process model will start running today at 6PM then should stop running at 5AM the next day. Now I need to create a validation where it returns true/false to check if the execution time is still within the range. Hope anyone could help me. Thank you.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    What exactly is your question? How to check the date, that would be "start >= date <= end"? Or is it about starting your process? What exactly do you mean with "start running today at 6PM then should stop running at 5AM the next day"?

    In general it is a best practice to just start processes in a certain interval and then have a XOR to check whether this exact moment in time is valid or not. But this depends on your actual use case.

  • I have a process model to run batch process which automatically triggers at 6PM today and should only run until 5AM the next day. It's looping it's own to collect another data before submitting it to the subprocess model. Now my question is, how to form a script that returns true/false to check if the execution time is still within the time range which is 6PM today until 5AM the next day. So the next time my process model calls itself again and it 5:01 AM, it should proceed on the end node.

    Hope I made it clear. Thank you for your time.

  • 0
    Certified Lead Developer
    in reply to Sarah B.

    Did you try to add a XOR gateway using a condition of "now() > pv!endDate"? I simple date comparison evaluates to your desired true/false.

    Now, your can calculate the endDate using the a!addDateTime() function in the initial start and pass it along to the next calls.

  • Hi Stefan, yes I have an xor to check, I am just having trouble with my logic how to create that script. However, I came up with this. I am not exactly sure if the logic is good enough. So my process model automatically runs at 6PM. So my xor will check if the time now is already 5AM. The logic here is I just need to find a way to tell the PM to stop. Then my process model will start running again at 6PM the next day and will end 5AM the day after.

    a!localVariables(
        local!dateTime: right(text(ri!timeNow,"hh:mm AM/PM"),2),
        local!castTime: cast(8, local(ri!timeNow)),
        if(
          local!dateTime = "AM",
          local!castTime < totime("5:00 AM"),
          local!castTime > totime("5:00 AM")
        ) 
      )

    If you have any better input than what I have made, I'll be more than glad to take a look. Thank you.

  • 0
    Certified Lead Developer
    in reply to Sarah B.

    This logic seems to be over-complicated. But before diving into this, can you share a screenshot of your process model?

Reply Children