+ Reply to Thread
Results 1 to 6 of 6

INT function help

  1. #1
    Registered User
    Join Date
    09-30-2017
    Location
    Toronto, Canada
    MS-Off Ver
    Microsoft Office 2010
    Posts
    10

    INT function help

    Hello,

    I request anyone's help in this simple sounding, but difficult (for me) formula problem.

    I was given a population and I would need to calculate their age using their birthday and what date they died. For the most part, I would have their Date of Birth (mm/dd/yyyy) and Date of Death (mm/dd/yyyy) and I used the following formula:

    =INT(YEARFRAC(A1,B1)) - A1 represents Date of Birth and B1 is Date of Death.

    But here is where I need help.

    For some of the population, I have their Date of Birth but not their Date of Death and for others, I would have their Date of Death but not their Date of Birth. These individuals would still need to be recorded in the spreadsheet but what seems to happen when I input the Date of Birth but not the Date of Death, it calcuates from 1900 and give me a squewed age. A similar calucation occurs if i have the Date of Death and not the Date of Birth.

    What I would like is two options: if I have Date of Birth but not Date of Death or vise versa I would like the age to remain as 0;
    and

    If have Date of Death but not the Date of Birth or vise versa, I would like the age to calcualte as N/A

    How do I put that in a formula?


    Thanks
    Last edited by heyz123456; 09-30-2017 at 11:48 AM.

  2. #2
    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,208

    Re: INT function help

    if I have Date of Birth but not Date of Death or vise versa I would like the age to remain as 0;

    and

    If have Date of Birth but not the Date of Death or vise versa, I would like the age to calcualte as N/A
    .... so which one?

    =IF(OR(DoB="",DoD=""),0,DoD-DoB)

    =IF(OR(DoB="",DoD=""),"#N/A",DoD-DoB)

  3. #3
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: INT function help

    Quote Originally Posted by heyz123456 View Post
    =INT(YEARFRAC(A1,B1)) - A1 represents Date of Birth and B1 is Date of Death.
    [....]
    if I have Date of Birth but not Date of Death or vise versa I would like the age to remain as 0;
    and
    If have Date of Birth but not the Date of Death or vise versa, I would like the age to calcualte as N/A
    Typo? I presume the last should read: if DoD, but not DoB, then N/A.

    Not clear if you mean literally "N/A" or the Excel error #N/A. I presume the first.

    =IF(B1="", 0, IF(A1="", "N/A", INT(YEARFRAC(A1,B1))))

  4. #4
    Registered User
    Join Date
    09-30-2017
    Location
    Toronto, Canada
    MS-Off Ver
    Microsoft Office 2010
    Posts
    10

    Re: INT function help

    Thank you Joeu2004, for providing me with the full function equation so that I can simply input in my excel cell. Also, you were correction in both presumptions.


  5. #5
    Registered User
    Join Date
    09-30-2017
    Location
    Toronto, Canada
    MS-Off Ver
    Microsoft Office 2010
    Posts
    10

    Re: INT function help

    Sorry JohnTopley for being a bit confusing, it was the former that I wanted.

  6. #6
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: INT function help

    Quote Originally Posted by heyz123456 View Post
    Thank you Joeu2004, for providing me with the full function equation
    You're welcome. But on second thought, perhaps the following is better for you:

    =IF(B1="", IF(A1="", "", 0), IF(A1="", "N/A", INT(YEARFRAC(A1,B1))))

    That way, if both A1 and B1 appear blank (no data yet), the formula returns the null string (""), so that the cell also appears blank. Good for building "templates".

+ 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. Calling function inside function. (aka nested function)
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2015, 05:58 AM
  2. VBA code for custom function that returns detail results of array function
    By onechipshot in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-10-2015, 06:30 PM
  3. Replies: 13
    Last Post: 04-08-2014, 05:46 AM
  4. Replies: 2
    Last Post: 01-15-2014, 11:40 PM
  5. [SOLVED] Using Offset function as the array in the PercentRank function is giving wrong result
    By Bobneil in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-06-2013, 09:29 PM
  6. Replies: 1
    Last Post: 03-21-2012, 11:22 AM
  7. Excel - User Defined Function Error: This function takes no argume
    By BruceInCalgary in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-18-2006, 04:05 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