ExcelTip.com
ExcelTip.com
Account Icon Account Icon Account Icon
Google Exceltip.com
JOIN OUR NEWSLETTER
  and receive for joining:
Free eBook Learn More!
Free Excel ADD-IN
Free Weekly Excel Tip
4 e-books in cd-rom
F1 Formulas & Functions
F1 Formulas & Functions
F1 EXCEL
F1 eBook (Spanish)
F1 EXCEL
Financial Statements.xls
 

» Working Out a Person's Age in Microsoft Excel
Tip Contributed by Martin Green.Martin Green, Office Tips is a freelance Access and Excel trainer and developer based in London.
CATEGORY: Excel Dates

How Excel Works with Dates

Excel considers dates as numbers. Each date is assigned a unique serial number. For example, the 27th September 1999 was date serial 36430. Fortunately, you don't need to know this but the fact that all dates have numerical values can be very useful. Windows uses the 1900 date system in which 1st January 1900 is date serial 1, 2nd January 1900 is date serial 2 and so on.

Checking the serial number of a dateWhen you type a date into a cell, Excel shows you a date but is thinking of a number. 

To find out the serial number of a date, select the cell containing the date then go to Format > Cells. Go to the Number tab and click General in the Category list. The date's serial number will appear in the Sample box on the right.

You can make use of these numbers in all sorts of ways. You can add a number to a date to give a date that number of days later (or subtract a number to get a date before), you can take one date from another to find out how many days in between. There are lots of ready-made date functions too.

Working Out a Person's Age

A person's age is the amount of time since they were born (I know you know that but the computer doesn't, and we have to start thinking like the computer). So, all we have to do is put today's date in one cell and the person's date of birth in another cell, then take their date of birth away from today and you get their age - right? Well, sort of... you get a number. Because you took a date serial from another date serial you get the number of days in between*[note]. It looks like this...

Age shown as a number of daysIn this example the formula in cell A3 is:

=A1-A2

 

 

We need to convert this number of days into a number of years. Most years have 365 days but every fourth year has 366 days. So the average number of years is 365.25. Let's modify our formula...

Age shown as a number of yearsIn this example the formula in cell A3 is:

=(A1-A2)/365.25

 

 

Note the brackets around the first part of the formula. Brackets mean "Work out this bit first...". I've used them here to stop Excel trying to divide A2 by 365.25 before taking it away from A1. Excel formulas work do any multiplying and dividing before it does adding and subtracting, but anything in brackets gets done first.

Now we can see a number of years, but it's still not quite right. We are getting an accurate result but we don't really want to see the fraction. As a last refinement we'll wrap the whole thing inside an INT() function to give us a whole number (an integer). This is better than changing the number of decimal places displayed, which would risk some numbers being rounded up and giving an incorrect result. Here's the finished result...

Age shown as whole yearsIn this example the formula in cell A3 is:

=INT((A1-A2)/365.25)

 

 

*Note: In fact, to start with, you get another date. Confused? Don't be... Excel is trying to help but has misunderstood what we need. In date calculations, the result cell gets automatically formatted the same way as the first cell in the formula. Because the first cell was formatted as a date Excel showed you the result as a date, although you wanted to see a number. Just reformat the cell manually by going to Format > Cells > General. [back]

^ top


Inserting Today's Date Automatically

You can save yourself the effort of entering today's date manually. Excel has a function, TODAY(), that creates the current date. All you need to do is place this function into the age calculation formula in place of the reference of the cell that had today's date in it...

Age calculation using the TODAY() functionIn this example the formula in cell A2 is:

=INT((TODAY()-A1)/365.25)

 

 

How accurate do you need to be?

This formula yields pretty accurate results but it isn't infallible. Dividing by the average number of days in a year works for most people most of the time, but sometimes it gets it wrong. Supposing the person in question is a child, who hasn't yet lived through a 366 day year, you should be dividing by 365 and not 365.25. So how can we get an exact, guaranteed correct figure? Read on...

^ top


Using Nested IF Statements to Tell It Like It Is!

Supposing it's August and you need to know old someone is...

  • The person was born in 1975. How old are they? You can't say.
  • The person was born in August 1975. How old are they? You still can't say.
  • A person was born on 23rd August 1975. How old are they? At last! You have enough information. You can say for certain.

In order to calculate someone's age precisely you need to know the year in which they were born, and whether or not hey have had their birthday.

If the have had their birthday you subtract their birth year from the current year. If they have not yet had their birthday you subtract their birth year from the current year, and then subtract 1. Easy! We do it all the time without thinking about it. But explaining the rules to Excel is a bit more complicated. Here goes...

=IF(MONTH(TODAY())>MONTH(A1),YEAR(TODAY())-YEAR(A1),
 IF(AND(MONTH(TODAY())=MONTH(A1),DAY(TODAY())>=DAY(A1)),
 YEAR(TODAY())-YEAR(A1),(YEAR(TODAY())-YEAR(A1))-1))

I've written this calculation on three lines for clarity but you should write is as a single expression without spaces. It assumes that cell A1 contains the person's date of birth. Here's what it says...

  • IF(MONTH(TODAY())>MONTH(A1)
    If this month is later than the month of the persons birthday...
  • YEAR(TODAY())-YEAR(A1)
    ...subtract the year in which they were born from this year because they must have had their birthday.

But what if we haven't passed the month in which they were born. We might be in that month, or we might not have reached it yet. Let's find out...

  • IF(AND(MONTH(TODAY())=MONTH(A1),DAY(TODAY())>=DAY(A1))
    If we are currently in the month of the person's birthday and it is either their birthday today or we have passed it...
  • YEAR(TODAY())-YEAR(A1)
    ...subtract the year in which they were born from this year because they must have had their birthday.

But what if this isn't the month in which they were born. We know we haven't passed their birthday so...

  • (YEAR(TODAY())-YEAR(A1))-1
    ...subtract the year in which they were born from this year then subtract 1, because they haven't had their birthday yet.

Phew!

^ top


About IF Statements

An IF statement contains three parts:

IF(Logical Test,Value If True,Value If False)

Logical Test: This is a question or circumstance than can be answered yes or no, or true or false.

Value If True: This is what the function should do if the answer to the test is yes or true.

Value If False: This is what the function should do if the answer to the test is no or false.

In other words, you ask a question. If the answer is yes you do one thing. If the answer is no you do something else. What the IF statement does could be to display a number or piece of text, or it can do a calculation (which is what is does in the example I've used here).

But what if you don't have a simple yes/no question. The solution is a nested IF statement. Instead of inserting a number, piece of text or calculation, the value if true or value if false part (or both parts) can be IF statements themselves. They normally need a bit of working out (!) because they have to use the same logical process as Excel does. If it doesn't work first time, try writing it a different way. And try "translating" it into English as I did above.

A nested IF statement says something like...

"If the answer is yes, do this. If the answer is no do this or this (depending on..."

And if you think the Age Calculator is complicated, consider the fact that Excel can handle up to seven (count them!) nested IF statements in a single calculation.



Rate this tip
12 34 5
  RATING: 4.07
  VIEWS: 124567

READER COMMENTS (view all comments)


working out a person's age
tamra_t wrote on December 31, 1969 19:00 EST
Thank you, Thank you, Thank you. I could not figure this one out no matter how much I tried. Thank you, Thank you, Thank you!
if statements
if wrote on December 31, 1969 19:00 EST
how do you do more than 7 nested if statements
Working Out a Person's Age in Excel
Lani Braga wrote on December 31, 1969 19:00 EST
Please help me to calculate person's age.
I want the result to be in Years, Months and days just in one formula:
Example, If I was born on 21 Dec 1966 my will is
39 Years, 1 Month and 4 days.

I highly appreciate for your prompt reply.

Thanks
Calculate Age
Lani Braga wrote on December 31, 1969 19:00 EST
Please help me calculate person;s age.
I want the result in years, month and days.

Example: Birthday 21 Dec 1966
Result / Age is 39 years, 1 month and 4 days

Thanks
Lani - here's your answer
JP wrote on December 31, 1969 19:00 EST
http://www.cpearson.com/excel/datedif.htm
Calculating Age
Sreeraman.TS wrote on December 31, 1969 19:00 EST
http://www.cpearson.com/excel/datedif.htm

Explanatory Notes given by above Site is so clear & extremely helpful. I admire the functionality providers of EXCEL - in their Excellent way of concepts...

Thanks to all the wonderful people for conceiving & also helping others to use.

Can some one help me what to do if there are more than 7 Nested IF funcationality that I come across! Why Seven & Why Not More??

Sreeraman.TS
April 01, 2006
Time for their b-day
Cerestly wrote on December 31, 1969 19:00 EST
I need to know how to get the formula right to calculate the days (if the persons bday hasn't passed on the current year) till his/her b-day.

Please help me.
WHAT AGE CAN YOU START WORKING OUT
Daniel wrote on December 31, 1969 19:00 EST
WHAT AGE CAN I START WORKING OUT I START RIGHT KNOW I NOW THAT IM 15 YEARS OLD BUT THE PROMBLEM IS WILL IT AFFECT MY GROWTH WILL I GROW TALLER SLOWER OR JUST NORMALY RIGHT NOW IM 6 FOOT 2 IM LOOKING TO GET IN THE NBA SO IM WONDER WILL IT AFFECT THE WAY I GROW?
how to convert the figure to words
praveen verma wrote on December 31, 1969 19:00 EST
i want to know is it possible to convert the numerical to words. suppose if i insert the 222 then it should show me two hundred and twenty two.
if yes then how should i do it.


pls mail me on
pverma@jeena.co.in
An alternative
Adrian G wrote on December 31, 1969 19:00 EST
I find it easier to use a sort of boolean logic rather than if statements. I personally find it easier to follow, but thats probably just cos its my method!

=YEAR(TODAY())-YEAR(A1)+((MONTH(TODAY())-MONTH(A1))>0)*1+(MONTH(TODAY())=MONTH(A1))*(DAY(A1)>=DAY(TODAY()))*1-1
IM 15 BUT FORGOT MY YEAR
GEMMA wrote on December 31, 1969 19:00 EST
I HAVE FORGOTTEN MY BIRTHDAY YEAR
Calculating Age
Nelson wrote on December 31, 1969 19:00 EST
Would be able to come up with a formula to calculate an age up to the exact second?
how to convert the figure to words
Muthukumaran Sarangapani wrote on December 31, 1969 19:00 EST
i want to know is it possible to convert the numerical to words. suppose if i insert the 222 then it should show me two hundred and twenty two.
if yes then how should i do it.

pls mail me on
msarangapani@officetiger.com
CALCULATING YEAR TO YEAR AGE
CMB wrote on December 31, 1969 19:00 EST
I want to have aformula where it calculates years of age continous; for example i want to know what age someone will be this year, next year, etc.
CALCULATING YEAR TO YEAR AGE
CMB wrote on December 31, 1969 19:00 EST
I want to have aformula where it calculates years of age continous; for example i want to know what age someone will be this year, next year, etc.
nice formula right here
Elmwoodie wrote on December 31, 1969 19:00 EST
its never too early to workout. and a better formula for age calculation is at http://www.ozgrid.com/Excel/calculate-age.htm
Another Method
Paul M^ wrote on December 31, 1969 19:00 EST
I did it this way...

=YEAR(TODAY())-YEAR(A1)-IF(MONTH(TODAY())*100+DAY(TODAY())<MONTH(A1)*100+DAY(A1),1,0)



REGISTERED USERS - Click here to post comments


GUESTS (Click here to register)
Name
Comment Title
Comments

Financial Statement Analysis: A Practitioner's Guide, 3rd Edition

Windows XP for Dummies

The Accounting Game : Basic Accounting Fresh from the Lemonade Stand

Treason: Liberal Treachery from the Cold War to the War on Terrorism

How to Read A Financial Report

Fish! A Remarkable Way to Boost Morale and Improve Results

RELATED MICROSOFT EXCEL TIPS


Convert PDF Files to Excel






Excel VBA books
Accounting books
Business Plans
MS Office books
Taxes books

VIEW ALL BOOKS


  Advertise With Us                               

Tips

Add-In in VBA | Applications - Word, Outlook in VBA | Array Formulas | Cells, Ranges, Rows, and Columns in VBA | Counting | Custom Functions | Custom Functions in VBA | Database Formulas | Database in VBA | Date & Time Formulas | Date & Time in VBA | Events in VBA | Excel 2003 | Excel Chart | Excel Consolidating | Excel Counting | Excel Custom Functions using VBA | Excel Customizing | Excel Data | Excel Dates | Excel Editing | Excel Files | Excel Filter | Excel Format | Excel Formula | Excel General | Excel Grouping and Outlining | Excel Importing Text Files | Excel Information | Excel Keyboard Shortcuts | Excel Loan Formulas | Excel Macros - VBA | Excel Pivot Tables | Excel Printing | Excel Range Name | Excel Security - Protection | Excel Sorting | Excel Style | Excel Subtotals | Excel Summing | Excel Text | Excel Time | Excel Tools | Excel Worksheet, Workbook | Files, Workbook, and Worksheets in VBA | Financial Formulas | Formating in VBA | General Topics in VBA | Import and Export in VBA | Information Formulas | Keyboard & Other Shortcuts in VBA | Keyboard Formula Shortcuts | Links between Worksheet and Workbooks | Links in VBA | Logical Formulas | Lookup Formulas | Mail - Send and Receive in VBA | Menus, Toolbars, Status bar in VBA | Modules, Class Modules in VBA | Other Q&A Formulas | Printing in VBA | Protecting in VBA | Summing | Text Formulas | User Forms, Input boxes in VBA | Using Loops | Working with Formulas |

Tips by Version

Microsoft Excel 97 | Microsoft Excel 2000 | Microsoft Excel 2002 | All Microsoft Excel Versions | New in Excel 2002 | New in Excel 2003 - Office 11

Website

Home | Tip of Hour | Recommended Tips | Most Viewed Tips | Tips by Version | Submit a Tip | My Tips
Microsoft Excel Tutorials | Excel Links | Write for Us | About Us | Search Results | Tip Archives | Excel Forum | Excel Forum Archives

Excel Book

Excel 97 Book | Excel 2000 Book | Excel 2002 Book | Excel XP Book | Book Store

Terms and Conditions of use
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.

Copyright © 2003 ExcelTip.com
Microsoft, Microsoft Excel is a U.S. registered trademark of Microsoft Corporation
Site Developed By: Varien