In our automation processes, we might come across situations where we are required to switch between various workflows based on time.
So how can we do that?
Datetime.Parse(DateTime.Now.ToString(“HH:mm:ss”)) < datetime.Parse(_Time)
Note:
Replace the “_Time” with your required “TimeSpan” .i.e 18:00:00, 02:00:00…
Example
Implementation using UiPath :
Let us implement a workflow which compares the current time with the provided time and displays the appropriate messages.
Step 1:
Drag “If” activity into the design panel and populates its condition property with the above-mentioned code with “18:00:00” in it.
Step 2:
Drag “Message Box” activity into the design panel and write “Before 6pm” in it.
Step 3:
Drag “Message Box” activity into the design panel and write “After 6pm” in it.
Step 4:
Finally
Based on the current time, we can see the appropriate message.
Click here to download the Source Code…
Hope it has helped you…