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

Note:
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

Example

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

Note:
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…

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: