How To Compare Time In UiPath

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.

UiPath Compare Time 1.PNG

Step 2:
Drag “Message Box” activity into the design panel and write “Before 6pm” in it.

UiPath Compare Time 2.PNG

Step 3:
Drag “Message Box” activity into the design panel and write “After 6pm” in it.

UiPath Compare Time 3.PNG

Step 4:
Finally
Based on the current time, we can see the appropriate message.

UiPath Compare Time 4.PNG

 

Click here to download the Source Code…

Hope it has helped you… 

Advertisements

Author: Sharath Raju

Founder@www.ExcelCult.com

Leave a Reply