+ Reply to Thread
Results 1 to 22 of 22

Excel formula years service between years

  1. #1
    Forum Contributor
    Join Date
    03-16-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    135

    Excel formula years service between years

    Hi All

    I am trying to work out a formula which gives me:

    years serviced aged below 22:
    Years service aged 22 + & below 41:
    Years service aged 41 +


    I have the following information:
    DOB: 1/08/1974
    Start date of employment: 5/09/1974
    END date of employment:31/12/2015

    Length of service: 41
    Age:57

    Can anyone help me??

    Thank you!!
    Last edited by vba1234; 11-25-2015 at 01:42 PM.

  2. #2
    Forum Expert
    Join Date
    09-20-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    2,278

    Re: Please can someone help with this formula!!

    Hello
    The DATEDIF function is useful in this situation, Start Date in A2 and End Date in A3:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    DBY

  3. #3
    Forum Contributor
    Join Date
    03-16-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Please can someone help with this formula!!

    Hi

    Thanks but I need a formula to work out how many years service they have done under the age of 22, years service between 22 and below 41, and years service aged 41+.

    Thanks for a quick reply

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Please can someone help with this formula!!

    I have the following information:
    DOB: 1/08/1974
    Start date of employment: 5/09/1974
    END date of employment:31/12/2015
    This person started work at a month old? That's some prodigy!
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,448

    Re: Please can someone help with this formula!!

    Thread descriptive Thanks
    Last edited by Pepe Le Mokko; 11-25-2015 at 01:59 PM.

  6. #6
    Forum Contributor
    Join Date
    03-16-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Please can someone help with this formula!!

    Apologies this should show:

    Start Date of employment: 5/09/1990

  7. #7
    Forum Contributor
    Join Date
    03-16-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Excel formula years service between years

    Hi All

    I have attached an example of the formulas that I need help with.

    Highlighted in yellow.

    Thanks
    Attached Files Attached Files

  8. #8
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Excel formula years service between years

    The datedif function should help.

    You just need to adjust the start and end dates to reflect dates at a persons specific age.

    If A1 is a person's birthdate, then their 22nd birthday is
    =EDATE(A1,12*22)

    So the number of years between your start date (say that's in B1), and their 22nd birthday is
    =DATEDIF(B1,EDATE(A1,12*22),"y")


    Hope that helps.

  9. #9
    Forum Contributor
    Join Date
    03-16-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Excel formula years service between years

    Hi Jonmo1

    Thanks, but in the spreadsheet, if the person started work at the age of 16, then the services below 22 should give me 5 etc. However I am not getting this formula to work in the spreadsheet when the dates are changes.



    Thanks

  10. #10
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Excel formula years service between years

    Adjusting for your actual references,
    Formula in E12 is
    =DATEDIF(C9,EDATE(C8,12*22),"y") - I get a result of 6
    Start Date (C9) is 5 Sep 1975
    Birth Date (C8) is 1 Jan 1960 (so 22nd birthday is 1 Jan 1982)
    There are 6 years between 5 Sep 1975 and 1 Jan 1982 (76 77 78 79 80 81)

  11. #11
    Forum Contributor
    Join Date
    03-16-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Excel formula years service between years

    Thanks Jonmo1

    How about the "Years service aged 22 + & below 41". The number of years they have worked between the age of 22 and below 41?

    Thanks you so much for your help

  12. #12
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Excel formula years service between years

    Just change the 22 to 41 to get the 41st birthday.
    That will give all years between start and 41
    Then subtract the result of the first formula for below 22.
    And for the over 41, use TODAY() instead of the EDATE, and subtract both the first 2 formulas.

  13. #13
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,215

    Re: Excel formula years service between years

    See attached for sample formulae which you should be able to transfer to your file.

    All DATEFDIF as per Jonmo1's formula with EDATE.

    For comparison I included calculations using month rather than year (replace "y" with "m")
    Attached Files Attached Files

  14. #14
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Excel formula years service between years

    Might need to incorporate the MIN function onto the END date to account for your Leave date in C10

    =DATEDIF(C9,MIN(C10,EDATE(C8,12*22)),"y")

  15. #15
    Forum Contributor
    Join Date
    03-16-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Excel formula years service between years

    Hi JohnTopley

    Thank you for this. However when I enter the following:
    DOB: 17/01/1991
    Start date: 30/06/2014
    end date: 31/12/2015

    This gives me "Age >=22 and <=41" = 17, this is incorrect. This should return 1. As this person has worked for 1year only.

    Thanks

  16. #16
    Forum Contributor
    Join Date
    03-16-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Excel formula years service between years

    Hi Jonom1

    I am looking for the number of years of service a person has done within the company. Will the MIN function needed?

    Thanks

  17. #17
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Excel formula years service between years

    Quote Originally Posted by vba1234 View Post
    Will the MIN function needed?
    Yes
    It's purpose is to return whichever date is earlier, the End Date or the Birthdate.
    Otherwise, it would include the years that are AFTER the End date, but before the Birthdate.

    You're welcome.

  18. #18
    Forum Contributor
    Join Date
    03-16-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Excel formula years service between years

    Hi Jonmo1

    Are you able to work this out in the sample sheet please, as I am getting bit confused.

    Sorry

  19. #19
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Excel formula years service between years

    I also added IFERROR to accomodate errors when the 22nd or 41st birthdate is actually before the Start Date.

    EFServiceYears.xlsx

  20. #20
    Forum Contributor
    Join Date
    03-16-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Excel formula years service between years

    Hi Jonmo1

    You are a GENIUS!!!!. Thank you so much. Really appreciated for the help.

    Thanks

  21. #21
    Forum Contributor
    Join Date
    03-16-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Excel formula years service between years

    Hi All

    Thank you JohnTopley and Jonom1, really appreciated for the help!.

    Thanks

  22. #22
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Excel formula years service between years

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 11
    Last Post: 06-06-2014, 03:34 PM
  2. how to hide formula in formula box, view lookup result in formula box?
    By vengatvj in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-14-2013, 04:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1