+ Reply to Thread
Results 1 to 6 of 6

DATEDIF anomaly?

  1. #1
    Registered User
    Join Date
    01-05-2004
    Location
    Perth, Western Australia
    Posts
    10

    DATEDIF anomaly?

    Hi there,
    Am getting a curious result when I use Date diff to return a result for 2 identical dates (except for year).

    When I do "=DATEDIF(A10,TODAY(),"YD")" ... where A10 = "4 Jun 2003" I get a result of 355.

    However, when I do "=DATEDIF(A11,TODAY(),"YD")" where A11 = "4 Jun 2005" I get a result of 354.

    Is anyone able to help me out as to why there is a day difference when the year should not matter?
    Is there a way around this?

    Many thanks in advance
    Andy

  2. #2
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by cruisy
    Hi there,
    Am getting a curious result when I use Date diff to return a result for 2 identical dates (except for year).

    When I do "=DATEDIF(A10,TODAY(),"YD")" ... where A10 = "4 Jun 2003" I get a result of 355.

    However, when I do "=DATEDIF(A11,TODAY(),"YD")" where A11 = "4 Jun 2005" I get a result of 354.

    Is anyone able to help me out as to why there is a day difference when the year should not matter?
    Is there a way around this?

    Many thanks in advance
    Andy
    Hi,
    isn't that 'anomaly' called Leap Year (2004)

    hth
    ---
    Si fractum non sit, noli id reficere.

  3. #3
    Registered User
    Join Date
    01-05-2004
    Location
    Perth, Western Australia
    Posts
    10
    Yes - true thanks for that - I guess the confusion for me was that the Microsoft Excel Help stated that by using the qualifying unit of "YD" that "The difference between the days of start_date and end_date. The years of the dates are ignored."

    My problem is that I am wanting to find a simple way to work out the number of days from now until a person's birthday. The problem within this is that 2 people share the same birthday but are born in different years ie 2003 and 2005. Thus using Datedif (ignoring the year function) I arrive at different results... is there a better way to do it?

    Many thanks in advance (again) if you reply to this
    Cheers
    Andy
    Last edited by cruisy; 05-24-2007 at 04:23 AM.

  4. #4
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by cruisy
    Yes - true thanks for that - I guess the confusion for me was that the Microsoft Excel Help stated that by using the qualifying unit of "YD" that "The difference between the days of start_date and end_date. The years of the dates are ignored."

    My problem is that I am wanting to find a simple way to work out the number of days from now until a person's birthday. The problem within this is that 2 people share the same birthday but are born in different years ie 2003 and 2005. Thus using Datedif (ignoring the year function) I arrive at different results... is there a better way to do it?

    Many thanks in advance (again) if you reply to this
    Cheers
    Andy
    instead of "YD" why not use "D" and perhaps ignore any Datedif > 370 ?

    amend that to, isn't their birthday on the same day each year? - what is the real problem? just that you have a leap day for one birthday?

    added - try something like:

    =DATEDIF(DATE(YEAR(TODAY())-1,MONTH(A9),DAY(A9)),TODAY(),"YD")

    hth
    ---
    Last edited by Bryan Hessey; 05-24-2007 at 04:52 AM.

  5. #5
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    Hi

    You can give the following a shot - it should always return the number of days (from Today) of a person's next birthday, given that their birthdate is in A1 (which is what I assumed you wanted to do). The times when this may screw up will be if said person was born on 29th feb.

    =IF((TEXT(A1,"dd-mmm-")&YEAR(TODAY()))+0>TODAY(),(TEXT(A1,"dd-mmm-")&YEAR(TODAY()))-TODAY(),(TEXT(A1,"dd-mmm-")&YEAR(TODAY())+1)-TODAY())

  6. #6
    Registered User
    Join Date
    01-05-2004
    Location
    Perth, Western Australia
    Posts
    10

    Thumbs up

    Awesome - works a treat - thanks for that!

+ 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