Script to keep checking if 9:08am and execute a sequence and stop loop

I’m trying to make a script, which is part of a big script to

  1. Keep checking if time between 9:07 am - 9:09 am, if past 9:09, stop checking (Eg: Starting script at 10:30 am)
  2. Execute a sequence at exact 9:08 am → Break

Code I tried in while/if, not making sense as of now

Not Datetime.ParseExact(DateTime.Now.ToString("hh:mm"), "hh:mm", system.Globalization.CultureInfo.InvariantCulture) = datetime.ParseExact(NSE_PO_exact, "hh:mm", system.Globalization.CultureInfo.InvariantCulture) And
Datetime.ParseExact(DateTime.Now.ToString("hh:mm"), "hh:mm", system.Globalization.CultureInfo.InvariantCulture) >= datetime.ParseExact(NSE_PO_start, "hh:mm", system.Globalization.CultureInfo.InvariantCulture) And
Datetime.ParseExact(DateTime.Now.ToString("hh:mm"), "hh:mm", system.Globalization.CultureInfo.InvariantCulture) <= datetime.ParseExact(NSE_PO_end, "hh:mm", system.Globalization.CultureInfo.InvariantCulture)

NSE_PO_exact = “9:08”
NSE_PO_start = “9:07”
NSE_PO_end = “9:09”

I was trying to use while loop to check if time between 9:07 and 9:09 but not equal to 9:08

Please advice!

Hi @Munish_Jain1

Try sometime like this

along with delay u can add the process u need to run

FlowSwitch condition : Now.TimeOfDay>TimeSpan.Parse("9:09")

Regards,
Nived N

1 Like

Hi @Munish_Jain1,

Another design consideration will be to not use UiPath Robot license at all to check for a specific time. The robot does not need to wait until 9:08am and you can free up you UiPath license. I recommend you use advanced scheduling from Orchestrator / Trigger your robot from PowerShell using Orchestrator APIs or Trigger an unattended robot using time trigger from Windows Task Scheduler.

If this is already considered or you want the logic within the UiPath robot then you can ignore the suggestion mentioned above and use the logic from @NIVED_NAMBIAR

1 Like

Thank you @NIVED_NAMBIAR, added another flow decision for end time

Thank you for your input @jeevith , it’s a good idea but I’ve my main script running at that time.

1 Like

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