Calculating Difference of two dates in year month and day like datedif function in ms. excel

I am creating an application where I want to display the number of years, months and days between 2 dates but it is like DATEDIF Function on Ms. Excel

for Years : Returns the total number of years that have passed between two dates . its like a function on ms. excel =datedi(startdate,enddate,“Y”)

for Month : Returns the month difference in StartDate and EndDate. Differences in Days and years from the date are ignored. its like a function on ms. excel =datedi(startdate,enddate,“YM”)

For Days :Returns the difference of days in StartDate and EndDate. Year difference from date is ignored. its like a function on ms. excel =datedi(startdate,enddate,“YD”)

This is the example

Star Date : 22/7/2019
End Date : 26/8/2020

the result is

Years : 1
Months : 1
Days : 5

I can’t use ordinary calculations such as changing the number of days into years and months by dividing by 365 days, because I also take into account that there are leap years which have 366 days, so I need a special solution for this so that the calculation is accurate. and now I only find it in excel formulas namely in DATEDIF

Other Exampel

Star date : 31/12/2018
End Date : 1/3/2020 ( March 1 2020)
Result : 1 year 2 month 1 day

thank you, hope it have a solution

To do this you can use some free extensions like

And @bodymindpower extension also is there

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.