How To Find The Date Difference(Days, Months and Years) – In UiPath

Date operations are the most frequently used in business automation.

In a few business automations, decisions have to be taken based on the date differences.

Let’s see how to do that…!!!

required_Difference = DateDiff(DateInterval.Day,Convert.ToDateTime(_date1),Convert.ToDateTime(_date2)).Tostring

1. Replace the “_date1” with your first “Date”
2. Replace the “_date2” with your second “Date”
3. For day difference use – Dateinterval.Day
4. For month difference use – Dateinterval.Month
5. For year difference use – Dateinterval.Year


Implementation using UiPath :

Let us implement a workflow which takes two dates and displays the day difference.

Step 1:
Drag “Message Box” activity into the design panel and populate it with the above-mentioned code.

UiPath Days,month and year difference in UiPath.png

Date1 = "1/1/2019"
Date2 = "1/30/2019"

Step 2:
Finally, when you try to run the workflow
We will get the day difference, in this case.

UiPath Days,month and year difference in UiPath 2.PNG

Similarly, you can month and year differences 🙂

Click here to download the Source Code…

Hope it has helped you…




Sharath Raju

Author: Sharath Raju


Leave a Reply