Help with "Time of Service" formula

dallen8028

New Member
Joined
Jan 28, 2013
Messages
48
The formula below calculates "Time of Service" of many employees with different start dates. The years and months calculate correctly but the number of days are all the same when they should be different.

=DATEDIF([@[Seniority Date]],$F$2,"y")&" years," &DATEDIF([@[Seniority Date]],$F$2,"ym")&" months,"&$F$2-DATE(YEAR($F$2),MONTH($F$2),1)&" days"

Using MS Office Pro 2016. Please advise

Thanks in advance.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Try this:
Code:
=DATEDIF([@[Seniority Date]],$F$2,"y")&" years," & DATEDIF([@[Seniority Date]],$F$2,"ym")&" months," & DATEDIF([@[Seniority Date]],$F$2,"md")&" days"

If this helped you, please hit the "Like this post" button above.
 
Upvote 0
You're welcome. Glad it helped. Thanks for leaving feedback!
 
Upvote 0
Try this:
Code:
=DATEDIF([@[Seniority Date]],$F$2,"y")&" years," & DATEDIF([@[Seniority Date]],$F$2,"ym")&" months," & DATEDIF([@[Seniority Date]],$F$2,"md")&" days"

If this helped you, please hit the "Like this post" button above.

Mr. Jakeman, With the above formula. I have an employee that has left. I wish to add a section to the formula to stop time in service on the last day of employment. Please advise. Thanks in advance
 
Upvote 0
What date value is in $F$2? Is that today's date? If you are able to pull employee termination dates out of our HR system, I would use it in your data set. I might try to do something like this, imagining that Termination Date is a real field that you could pull out of your system. If an employee is active then the Termination Date field would be blank and you would apply the previous formula to evaluate the difference between Today() and the Seniority Date, otherwise take the difference between Termination Date and Seniority Date.

Code:
=IF([@[Termination Date]]="",DATEDIF([@[Seniority Date]],TODAY(),"y")&" years," & DATEDIF([@[Seniority Date]],TODAY(),"ym")&" months," & DATEDIF([@[Seniority Date]],TODAY(),"md")&" days",DATEDIF([@[Seniority Date]],[@[Termination Date]],"y")&" years," & DATEDIF([@[Seniority Date]],[@[Termination Date]],"ym")&" months," & DATEDIF([@[Seniority Date]],[@[Termination Date]],"md")&" days")
 
Upvote 0
This works great for what I asked. Thanks. What has to be added in order to keep the "calculated" cell blank when there is no date available? I do not have access to everyone's hire date yet. This will help keep the column clean until dates are inserted. I've tried adding the AND after the first IF and including the other date but it gives me an error of too many arguments. Please advise...?
 
Upvote 0
It would only be necessary to handle blanks when the Seniority Date is not available. So in that case, you could do something like:

Code:
=IF([@[Seniority Date]]="","",IF([@[Termination Date]]="",DATEDIF([@[Seniority Date]],TODAY(),"y")&" years," & DATEDIF([@[Seniority Date]],TODAY(),"ym")&" months," & DATEDIF([@[Seniority Date]],TODAY(),"md")&" days",DATEDIF([@[Seniority Date]],[@[Termination Date]],"y")&" years," & DATEDIF([@[Seniority Date]],[@[Termination Date]],"ym")&" months," & DATEDIF([@[Seniority Date]],[@[Termination Date]],"md")&" days"))
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top