Consulting

Results 1 to 13 of 13

Thread: Solved: ANNIVERSARY YEARS

  1. #1

    Solved: ANNIVERSARY YEARS

    How can I create a formula that will tell me how many years my employee has worked for our company from their Anniversary Date (hire date) to the current date?

  2. #2
    VBAX Regular
    Joined
    Feb 2008
    Posts
    54
    Location
    If the anniversary date was in cell "A1":

    =YEAR(TODAY())-YEAR(A1)

  3. #3
    Quote Originally Posted by MikeO
    If the anniversary date was in cell "A1":

    =YEAR(TODAY())-YEAR(A1)
    Mike, thanks. Did not work for me. I put this in
    =YEAR(TODAY())-YEAR(D19) and it gave me back a date rather than a number representing years.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    =DATEDIF(D19,TODAY(),"Y")
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5

    ANNIVERSARY

    Quote Originally Posted by xld
    =DATEDIF(D19,TODAY(),"Y")
    PUT THIS IN
    =DATEIF(D19,TODAY(),"Y")

    ITgave me an error sign

  6. #6
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    They both work for me......
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  7. #7
    VBAX Regular
    Joined
    Feb 2008
    Posts
    54
    Location
    The equation I gave you works for me. I think you just need to format the cell with the equation to be a number.

  8. #8

    ANNIVERSARY

    Quote Originally Posted by MikeO
    The equation I gave you works for me. I think you just need to format the cell with the equation to be a number.
    Wonderful, Mike. You were right. My cells were formated for DATE. As soon as I formated them for NUMBER it worked.

    THANKS MUCH.

  9. #9
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    raziel, If you got the solution for your question please mark your thread solved using the thread tools at the top of the page.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  10. #10
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    Hmmm if I use your example Steve, and place the date 12/5/1987 in A2 as indicated..... I get two different results. MikeO gives me 21 whilst Bob's give me 20.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  11. #11
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    That is because Mike's simply takes the lower year from the higher, so 31/12/2007 and 01/01/2008 are years 2007 and 2008 which is 1. If you use DateDif, it is calculating the number of years, and (correctly IMO) concludes here that 1 day is not a year, even if those days are in different years. That is why I offered DateDif
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  12. #12

    ANNIVERSARY FORMULA

    Quote Originally Posted by xld
    That is because Mike's simply takes the lower year from the higher, so 31/12/2007 and 01/01/2008 are years 2007 and 2008 which is 1. If you use DateDif, it is calculating the number of years, and (correctly IMO) concludes here that 1 day is not a year, even if those days are in different years. That is why I offered DateDif
    Thanks, much, XLD.

  13. #13
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Good catch Ted.
    This was informative......thanks to all.....especially Bob.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

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