+ Reply to Thread
Results 1 to 5 of 5

Count Years Between Two Dates

Hybrid View

  1. #1
    Registered User
    Join Date
    07-28-2009
    Location
    Grand Haven, MI USA
    MS-Off Ver
    MS Office 2007 Standard Edition
    Posts
    17

    Question Count Years Between Two Dates



    I have been trying to create an employee data sheet that will show me the number of years an employee has worked for the company by subtracting the employees hire date from todays date. What I have tried so far does not work. not sure what I have done wrong.

    todays date comes from feild F1 and looks like this "=TODAY()"

    then I have the hire date feild C4 which is formatted to look like this "01/14/2008"

    the years worked feild D4 is formated as a number and should look like this "3"

    I have tried two formula's for D4 they are as follows:

    1st: "=YEAR(F1)-YEAR(C4)" this is what it returns "1900"

    2nd: "DATEIF(F1,C4,"y")" this returns "#NAME?"

    any help would be greatly appreciated.

    I have also noticed on other excel spreadsheets that when I open a document, the dates do not always refresh (ie. "TODAY()") is there a setting that will refresh a function when opening a file?

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Count Years Between Two Dates

    Hi,

    The first should be correct. Are you certain C4 is a date number?

    Upload the workbook so that we can take a look

    Regards
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Count Years Between Two Dates

    There is a typo in your second formula its is DATEDIF not DATEIF

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,695

    Re: Count Years Between Two Dates

    Quote Originally Posted by sgwilliams View Post
    "=YEAR(F1)-YEAR(C4)" this is what it returns "1900"
    Are you sure D4 is formatted as number? - returning 1900 would suggest you have D4 custom formatted as yyyy
    Audere est facere

  5. #5
    Registered User
    Join Date
    07-28-2009
    Location
    Grand Haven, MI USA
    MS-Off Ver
    MS Office 2007 Standard Edition
    Posts
    17

    Thumbs up Re: Count Years Between Two Dates

    Ok I figured it out, it was a couple of things. The mispelled funtion was part of the problem thank you arthurbr. The other problem was the order in which the dates was shown in the funtion. See example as follows:

    =DATEDIF(C4,F1,"y") <-----correct order
    =DATEDIF(F1,C4,"y") <-----incorrect order

    hire date "C4" is 1/14/08
    todays date "F1" is 9/7/11

    Thanks for all the help fella's greatly appreciated!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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