Date Difference

Hi Friends,
I have to calculate the difference between the dates.
e.g Start date :- 05/12/2011
End date;- 07/12/2012

then output should be:- 368 days.
then how i do in uipath.

Regards,

Hi @Rup_1

You can use the DateDiff.
Use following code(example)
DateDiff(DateInterval.Day, “05-12-2011”,“07/12/2012”)

this activity returns the number of days difference between 2 dates.

Hope It helps!

Regards,
Naveen

1 Like

Hi,
I used above syntax it gives me error:-

Please guide me on this.
Variable type is Int 32.

Hi @Jayesh_678,

Try this

(EndDate - StartDate).TotalDays

Hi,
It is correctly calculating but giving output in decimal numbers.
Untitled

@Jayesh_678

This will work
(EndDate.Date - StartDate.Date).TotalDays

1 Like

I want output as a integer, number of days.

start date = 05/12/2011
End date = 07/12/2012
Create Variable of type (DateTime)
DateTimeStart = DateTime.Parse(start date)
DateTimeEnd = DateTime.Parse(End date)
MonthDifference Int type variable
MonthDifference = 12 * (DateTimeEnd.Year - DateTimeStart.Year) + DateTimeEnd.Month - DateTimeStart.Month

@Jayesh_678 Cheers

1 Like

This is working correctly. Thanks for your quick response.

Most Welcome @Jayesh_678 :slightly_smiling_face:

Hi,
There is an issue. Bot is unable to calculate the date difference for 2020 dates. Till 2019 dates, it is calculating perfectly.
But i want the date diff for 2020 dates also.
Please guide me on this.
@ClaytonM

@Jayesh_678 What is the issue and how do you pass the date?

Hi,

Try Microsoft.Activities package:

image

You can put start date and end date (datetime variable) in properties and you will receive int as a diff between those two in output