# Excel: Years of Service

I need a formula that will convert these two columns to a date.  Now I can do that by
=DATE(LEFT(E1,4),MID(E1,5,2),MID(E1,7,2))    and
=DATE(LEFT(F1,4),MID(F1,5,2),MID(F1,7,2))

but now I need to subtract Column E (start date) from Column F (Today's date) to calculate the length of time the employee has worked for the company.

KR
H--All-Employees-Years-of-Service.xlsx
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

IT Services ConsultantCommented:
Simply... the number of days will be:

=DATE(LEFT(F1,4),MID(F1,5,2),MID(F1,7,2)) - DATE(LEFT(E1,4),MID(E1,5,2),MID(E1,7,2))

You can then format that according to your needs, for example:

``````=DATEDIF(DATE(LEFT(E1,4),MID(E1,5,2),MID(E1,7,2)),DATE(LEFT(F1,4),MID(F1,5,2),MID(F1,7,2)),"y")&" years "&DATEDIF(DATE(LEFT(E1,4),MID(E1,5,2),MID(E1,7,2)),DATE(LEFT(F1,4),MID(F1,5,2),MID(F1,7,2)),"ym")&" months "&DATEDIF(DATE(LEFT(E1,4),MID(E1,5,2),MID(E1,7,2)),DATE(LEFT(F1,4),MID(F1,5,2),MID(F1,7,2)),"md")&" days"
``````

Please see columns [J], [K], [L], & [O] within the attached workbook.
Q-28701021.xlsx
Author Commented:
THANK YOU.  I am sending for verification and will close if accepted.

KR
Author Commented:
She said this is perfect but she wants to know what is the average # of years that employees have worked for the company,
IT Services ConsultantCommented:
OK, thank you for confirming the initial question has been answered as expected.

With the extended query, does your colleague wish to take account of local Public Holidays (& ignore any personal vacation time/any other absences)?  I am presuming this is probably too much to consider.

If the figure required is simply the total of all the days SUM(L1:L2379) = 8,900,970 divided by the number of employees (2379) with the result shown in years...

8,900,970 / 2,379 = 3,741.47541 (10 years 3 months 29 days)

See cell [O2382] of the updated attachment.
Q-28701021b.xlsx

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
Thank you again.
KR
Author Commented:
I hope I gave you credit for everything you helped me with.  I am very grateful.

KR
IT Services ConsultantCommented:
Yes; no issues at all.

Thanks for closing the question so promptly.

Good luck with the rest of the project.
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.