+ Reply to Thread
Results 1 to 12 of 12

Wrong Calculation

  1. #1
    Forum Contributor
    Join Date
    10-27-2013
    Location
    Ireland
    MS-Off Ver
    Microsoft 365
    Posts
    403

    Wrong Calculation

    i keep getting this answer 116 im calculation anniversary's from today's date but the person has not had an anniversary as they are very much alive so it should be leaving the cell blank but instead im getting the calculation 116 which should be blank

    my formula is
    =IFERROR(DATEDIF(F5,TODAY(),"Y"),"none")

    f5 is blank so i should be getting a return of none but its given 116

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Wrong Calculation

    Excel treats blank cells as 0 and DATEDIF(0, TODAY(), "Y") will not return an error.

    You need to check for F5 being blank instead of an error.

    =IF(F5="", "none", DATEDIF(F5,TODAY(),"Y"))
    If posting code please use code tags, see here.

  3. #3
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Wrong Calculation

    Deleted post
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  4. #4
    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,209

    Re: Wrong Calculation

    Maybe ...

    =IF(F5="","none",DATEDIF(F5,TODAY(),"Y")


    F5 blank (0) = 00/01/1900 in Excel

    Hence 116 (2016-1900)

  5. #5
    Forum Contributor
    Join Date
    10-27-2013
    Location
    Ireland
    MS-Off Ver
    Microsoft 365
    Posts
    403

    Re: Wrong Calculation

    Deleted post?

  6. #6
    Forum Contributor
    Join Date
    10-27-2013
    Location
    Ireland
    MS-Off Ver
    Microsoft 365
    Posts
    403

    Re: Wrong Calculation

    Quote Originally Posted by Norie View Post
    Excel treats blank cells as 0 and DATEDIF(0, TODAY(), "Y") will not return an error.

    You need to check for F5 being blank instead of an error.

    =IF(F5="", "none", DATEDIF(F5,TODAY(),"Y"))
    Yes F5 is blank except for formula

  7. #7
    Forum Contributor
    Join Date
    10-27-2013
    Location
    Ireland
    MS-Off Ver
    Microsoft 365
    Posts
    403

    Re: Wrong Calculation

    Quote Originally Posted by JohnTopley View Post
    Maybe ...

    =IF(F5="","none",DATEDIF(F5,TODAY(),"Y")


    F5 blank (0) = 00/01/1900 in Excel

    Hence 116 (2016-1900)
    Still returns 116

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

    Re: Wrong Calculation

    Then F5 is not blank.

    Can you post the formula you have in F5 ?
    Maybe it's actually 0, but you have 0's hidden via formatting or Advanced Options.

    Perhaps try
    =IF(F5=0,"none",DATEDIF(F5,TODAY(),"Y")

  9. #9
    Forum Contributor
    Join Date
    10-27-2013
    Location
    Ireland
    MS-Off Ver
    Microsoft 365
    Posts
    403

    Re: Wrong Calculation

    =IFERROR(INDEX('Player Database'!H:H,SMALL(INDEX(('Player Database'!$C$2:$C$5943=$A$1)*ROW('Player Database'!$C$2:$C$5943),0),COUNTIF('Player Database'!$C$2:$C$5943,"<>"&$A$1)+ROWS($5:5))),"")

  10. #10
    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,209

    Re: Wrong Calculation

    Then F5 <>"" !!!! Works OK for me.

  11. #11
    Forum Contributor
    Join Date
    10-27-2013
    Location
    Ireland
    MS-Off Ver
    Microsoft 365
    Posts
    403

    Re: Wrong Calculation

    Me too Thank you very much John your a life saver....

  12. #12
    Forum Contributor
    Join Date
    10-27-2013
    Location
    Ireland
    MS-Off Ver
    Microsoft 365
    Posts
    403

    Re: Wrong Calculation

    Quote Originally Posted by Jonmo1 View Post
    Then F5 is not blank.

    Can you post the formula you have in F5 ?
    Maybe it's actually 0, but you have 0's hidden via formatting or Advanced Options.

    Perhaps try
    =IF(F5=0,"none",DATEDIF(F5,TODAY(),"Y")
    Thank you works just as well as john's now to decide which 1

+ 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. [SOLVED] wrong calculation due to negative numbers?
    By loopiloo in forum Excel General
    Replies: 7
    Last Post: 12-06-2015, 11:54 AM
  2. IF formula calculation wrong
    By leakhna in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-27-2015, 10:26 PM
  3. wrong calculation value
    By cmccabe in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-05-2014, 01:17 PM
  4. [SOLVED] Help with SUMIF using multiple rows - wrong calculation
    By lulugonlolo in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-09-2012, 01:15 AM
  5. right calculation wrong answer
    By allinfernandez in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-06-2012, 10:07 AM
  6. wrong calculation when extending variable ranges
    By fxhst329 in forum Excel General
    Replies: 7
    Last Post: 01-30-2011, 05:37 PM
  7. Time Calculation-What am I doing wrong?
    By Latlong in forum Excel General
    Replies: 4
    Last Post: 10-14-2009, 01:51 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