Check the current time before starting process

I have a process that triggers via a queue trigger, it works brilliantly but I would like to put a little time check at the beginning to save a few issues that we occasionally come across.

So for example, the robot checks the current time is between 5:00am and 11:30pm before beginning. How can I do this? Can’t get my head around timespan variables

you could try in an if statement:

if TimeOfDay.tostring(“hh:mm:ss”) > “05:00:00” and TimeOfDay.tostring(“hh:mm:ss”) < “23:30:00”

1 Like

Let the Bot trigger as per queue trigger make change in logic so that Bot will not pick any queue items when it triggered in other timings not in the range of 5 to 11:30.

Make an if condition where you have logic to retrieve queue item (EX: Get transaction item) and bypass when the time is not within limit by below expression.

datetime.now < DateTime.ParseExact(Var_ststartime1.ToString.Trim,“hh:mm:ss tt”,CultureInfo.InvariantCulture) and datetime.now > DateTime.ParseExact(Var_startime2.ToString.Trim,“hh:mm:ss tt”,CultureInfo.InvariantCulture)

1 Like

currently using this approach and the robot is stopping the process because its ‘out of hours’ but it’s not its 14:50:00 so it obviously should be continuing

You can use the below condition in “If” Activity

now.TimeOfDay > CDate(“05:00:00”).TimeOfDay And now.TimeOfDay < CDate(“23:30:00”).TimeOfDay

This is working for now. Thanks.