ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   formula to caluclate the # of years and months between two dates (https://www.excelbanter.com/excel-worksheet-functions/120949-re-formula-caluclate-years-months-between-two-dates.html)

Alok

formula to caluclate the # of years and months between two dates
 
I think the calculation of the number of Years, Months and Days is not as
straight forward as one of the posts has implied. If someone joins on 12/1/05
then
=Month(Now())-Month("12/1/05") will give -1
Similarly negative numbers will be calculated in the day part of the
calculation.

I would suggest splitting up the calculation into three steps

If A2 has the join date then put formula for Year in B2. This will be
=IF(AND(YEAR(NOW())YEAR(A2),MONTH(NOW())MONTH(A2 ),DAY(NOW()DAY(A2))),DATEDIF($A$2,NOW(),"y"),0)

Put formula for calculating Months in C2. This will be
=DATEDIF(DATE(YEAR(A2)+B2,MONTH(A2),DAY(A2)),NOW() ,"m")

Put formula for calculating Days in D2 as follows
=DATEDIF(DATE(YEAR(A2)+B2,MONTH(A2)+C2,DAY(A2)),NO W(),"d")

There is probably a simpler approach. I would definately like to hear about
it.

"Christyepd" wrote:

I am setting up the employees lenths of service from the date hired until
present date.



All times are GMT +1. The time now is 07:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com