Difference between dates


I need to find difference between two below dates,can someone help me how to find in uipath

start date:07-03-2020
end date:022020

the result should be in months for the above it is 1 month difference between two dates.

  1. Convert both the dates into one format.
  2. Assuming start date is greater than end date and day of the month is irrelevant,
((startDate.Year - endDate.Year) * 12) + startDate.Month - endDate.Month


startDate.Subtract(endDate).Days / (365.25 / 12)

Hope this helps!


But my date format which comes will be in different formats

start date: “07-03-2020”
end date: “022020”

can you suggest me how to change format of end date so that it should be 00-02-2020.

You Can Use Date Parse method
example: Date.ParseExact(endDateVariable,“Date Format”,Nothing).ToString(“dd-MM-yyyy”)

Best Regards,
JothyPrasanth M

1 Like

Hi @Karthik_Kulkarni,

I’m sharing a workflow for your convenience. I hope you can find the solution.
BlankProcess8.zip (17.9 KB)

Please change the date values with your dynamic variables.

Thanks & Regards,

1 Like

Hi @apurba2samanta,

Your solution is working but when am dynamically reading values from an excel it is throwing an error .

Convert.ToInt32(Split(DateTime.ParseExact(row(“Date of Filing”).tostring, “dd-MM-yyyy”, System.Globalization.CultureInfo.InvariantCulture).ToString(“MM-yyyy”),“-”)(0))

in the above assign activity i gave as row(“columnname”).tostring so whether this is true.


Am attaching excel and what i tried can someone help me to in solving ,

I have two columns with different date formats ,i want third column as subtracted value.

Main.xaml (7.5 KB)
samplefile.xlsx (8.7 KB)

@Karthik_Kulkarni I have modified your xaml a bit, Check the Workflow, The Procedure what you followed was proper, but i guess the Excel value at first row was in a Different format . Hence It was not working. Was it a Mistake when editing or modifyng the file? or was the original Excel in the Same format ?

If it is the Original Format then we’ll need to perform additional Steps :sweat_smile:
Main.xaml (7.7 KB)

1 Like

Hi @supermanPunch ,

The first row was editing mistake ,but when i tried with your file am getting same old error


@Karthik_Kulkarni Then the Excel file was not reverted back to the Original File Format, Or can you share me the File that you are using, All the Rows should be in the Same format.

1 Like

sorry @supermanPunch,

I got what i want when i have changed some format.

thank you so much

1 Like

@Karthik_Kulkarni No need to be Sorry :sweat_smile:, It’s good that you have found out on on your own :smile:

1 Like

Hi @supermanPunch,

Actually you have subtracted only on basis of month, if i am adding year it is throwing an error

@Karthik_Kulkarni Yes, I got your point, I’ll try to correct it and revert it back.

@Karthik_Kulkarni If the Difference in Days is 35 between two dates, How many months of difference do you want it to Show up as?

Ha 2 months

Hi @supermanPunch,

Can u help me for the above issue.
If the difference is 35 we can consider it has 2 months.

@Karthik_Kulkarni Check this workflow if this is what you wanted :
Main.xaml (6.9 KB)

1 Like

It’s working for the year too with the above xaml.

But when am taking a new column with present time .And subtracting with second coulmn again it is throwing error as “String was not recognized”.

Attached excel for ur reference(Date1-Return date)coulmns.
samplefile.xlsx (8.8 KB)

@Karthik_Kulkarni But it works for me :sweat_smile:, What are the changes that you have performed to the xaml?