<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to create a rule to check if the time is within range</title><link>https://community.appian.com/discussions/f/data/28199/how-to-create-a-rule-to-check-if-the-time-is-within-range</link><description>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</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to create a rule to check if the time is within range</title><link>https://community.appian.com/thread/110099?ContentTypeID=1</link><pubDate>Tue, 28 Mar 2023 09:25:19 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:69e3cadf-4469-4b61-8d8b-130cf5a68159</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;That model seems to be OK. I think you should really calculate the desired end time when starting the process. Something like&lt;/p&gt;
&lt;p&gt;now() + intervalds(11, 0, 0)&lt;/p&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!tomorrow: today() + 1,
  datetime(
    year(local!tomorrow),
    month(local!tomorrow),
    day(local!tomorrow),
    5,
    0,
    0
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and store this in a PV and pass it along to the next iterations. Then your logic is just to compare now() vs. that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to create a rule to check if the time is within range</title><link>https://community.appian.com/thread/110098?ContentTypeID=1</link><pubDate>Tue, 28 Mar 2023 09:15:55 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:021dbbd4-f27c-4a51-b51c-e4cd0e02d8b2</guid><dc:creator>ankitab535847</dc:creator><description>&lt;p&gt;can you use something like this?&lt;pre class="ui-code" data-mode="text"&gt;localvariable(
local!currentTime: now(),
local!finalTime:time(5,0,0,0),

timevalue(local!currentTime)&amp;lt;local!finalTime
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to create a rule to check if the time is within range</title><link>https://community.appian.com/thread/110097?ContentTypeID=1</link><pubDate>Tue, 28 Mar 2023 09:10:45 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6ca030d2-533f-4b21-94d1-b2979981f1f7</guid><dc:creator>Sarah B.</dc:creator><description>&lt;p&gt;Below is my process model.&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/16/pastedimage1679994563628v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Then inside my xor can run, I have an expression with the code below:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;= and(
  rule!SPM_IsProcessEnabled(pmUUID: pm!uuid),
  rule!DAO_ToRunHistoricalProfileDeletion(timeNow: now())
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to create a rule to check if the time is within range</title><link>https://community.appian.com/thread/110096?ContentTypeID=1</link><pubDate>Tue, 28 Mar 2023 09:05:50 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9f0288ee-f28a-4a2d-9ca4-6e052c2787d3</guid><dc:creator>Sarah B.</dc:creator><description>&lt;p&gt;Hello there, I already have the XOR my problem is how to put a logic where the xor will redirect to end node if the time is beyond 5AM. If I use the logic now() &amp;gt; totime(&amp;quot;5:00 AM&amp;quot;) and the time is 12:00 AM onwards, then 12:00 AM &amp;gt; 5:00 AM is false which will lead to ending the process model early than the expected time limit. I came up with this script instead. I am just not confident with the logic if it&amp;#39;s appropriate&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
    local!dateTime: right(text(ri!timeNow,&amp;quot;hh:mm AM/PM&amp;quot;),2),
    local!castTime: cast(8, local(ri!timeNow)),
    if(
      local!dateTime = &amp;quot;AM&amp;quot;,
      local!castTime &amp;lt; totime(&amp;quot;5:00 AM&amp;quot;),
      local!castTime &amp;gt; totime(&amp;quot;5:00 AM&amp;quot;)
    ) 
  )&lt;/pre&gt;.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to create a rule to check if the time is within range</title><link>https://community.appian.com/thread/110095?ContentTypeID=1</link><pubDate>Tue, 28 Mar 2023 09:05:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8840e37e-d0ba-4abc-b4f7-ea2f437a74f3</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;This logic seems to be over-complicated. But before diving into this, can you share a screenshot of your process model?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to create a rule to check if the time is within range</title><link>https://community.appian.com/thread/110094?ContentTypeID=1</link><pubDate>Tue, 28 Mar 2023 08:59:58 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c7cdb8a4-649c-47d2-b0d5-27d9d73bd025</guid><dc:creator>Sarah B.</dc:creator><description>&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
    local!dateTime: right(text(ri!timeNow,&amp;quot;hh:mm AM/PM&amp;quot;),2),
    local!castTime: cast(8, local(ri!timeNow)),
    if(
      local!dateTime = &amp;quot;AM&amp;quot;,
      local!castTime &amp;lt; totime(&amp;quot;5:00 AM&amp;quot;),
      local!castTime &amp;gt; totime(&amp;quot;5:00 AM&amp;quot;)
    ) 
  )&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If you have any better input than what I have made, I&amp;#39;ll be more than glad to take a look. Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to create a rule to check if the time is within range</title><link>https://community.appian.com/thread/110092?ContentTypeID=1</link><pubDate>Tue, 28 Mar 2023 08:25:49 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f547b372-7f2b-4ac0-889d-64fda545f7e9</guid><dc:creator>ankitab535847</dc:creator><description>&lt;p&gt;Agree with Stefan.. When you are looping to restart the execution just put an XOR gate and check the time. If it&amp;#39;s more than 5am, end the process&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to create a rule to check if the time is within range</title><link>https://community.appian.com/thread/110091?ContentTypeID=1</link><pubDate>Tue, 28 Mar 2023 06:50:50 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:67e14c29-adac-42d2-9fdf-6f69337d635d</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Did you try to add a XOR gateway using a condition of &amp;quot;now() &amp;gt; pv!endDate&amp;quot;? I simple date comparison evaluates to your desired true/false.&lt;/p&gt;
&lt;p&gt;Now, your can calculate the endDate using the&amp;nbsp;a!addDateTime() function in the initial start and pass it along to the next calls.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to create a rule to check if the time is within range</title><link>https://community.appian.com/thread/110089?ContentTypeID=1</link><pubDate>Tue, 28 Mar 2023 06:44:30 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:300c02d3-da49-436c-99cc-64ccaeb7c9ec</guid><dc:creator>Sarah B.</dc:creator><description>&lt;p&gt;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&amp;#39;s looping it&amp;#39;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.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Hope I made it clear. Thank you for your time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to create a rule to check if the time is within range</title><link>https://community.appian.com/thread/110085?ContentTypeID=1</link><pubDate>Tue, 28 Mar 2023 05:50:23 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b678a544-5a46-413a-b8e1-c2fbeb29feac</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;What exactly is your question? How to check the date, that would be &amp;quot;start &amp;gt;= date &amp;lt;= end&amp;quot;? Or is it about starting your process? What exactly do you mean with &amp;quot;&lt;span&gt;start running today at 6PM then should stop running at 5AM the next day&amp;quot;?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;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.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>