How to find the year difference


I am having a list of multiple dates in an excel file.I want to compare that dates with today date and find the difference of that year. And show difference to the user.(Difference is in Year )
Date format :MMM/DD/YYYY


Hi @mnk

You can use DateDiff function to get the difference of years between two dates.
Syntax : DateAndTime.DateDiff("yyyy", Convert.ToDateTime(item(0).ToString.ToString),TodayDate)
TodayDate = DateAndTime.Now
please find the below attached workflow for your reference.
DateCalculation.xlsx (10.7 KB)
Year_Difference.xaml (8.1 KB)

Let me know if you face any issue.

Happy Automation

Hi @mnk

You can use the below one.

Hope this will be helpful. Thank you.

Int difference=Date1.Year - Date2.Year


Hi @mnk

You can follow the snippet given by @arivu96 in the case of both date variables is in DateTime type.

If the date variables storing the value as string, you can follow mine.

Thank you.