Often it is useful to show a person's age or years elapsed since a start date. For example:
=IF(ISBLANK(cellReference),"" --- this checks to see if there is a start date in your referenced cell. For example say your spreadsheet has a cell (A1) that holds a date of birth, but it is not yet referenced, this will result in an empty string. (Blank cell)
Otherwise, it calculates the years: DATEDIF(cellReference,TODAY(),"D")/365.2425)
DATEDIF compares two dates.
There you go!
Hire Date: 4/1/2012 - Years of service: 1.5Here's a formula for Numbers that will do the trick:
=IF(ISBLANK(cellReference),"",DATEDIF(cellReference,TODAY(),"D")/365.2425)
Replace the cellReference with the actual cell reference. i.e.: (A1)So here's the breakdown:
=IF(ISBLANK(cellReference),"" --- this checks to see if there is a start date in your referenced cell. For example say your spreadsheet has a cell (A1) that holds a date of birth, but it is not yet referenced, this will result in an empty string. (Blank cell)
Otherwise, it calculates the years: DATEDIF(cellReference,TODAY(),"D")/365.2425)
DATEDIF compares two dates.
The first date is your cell reference i.e.: (A1)
The second is the current date according to your computer, iOS device: TODAY() returning the Day - "D"
Then the difference is divided by 365.2425 to get the number of years. Set your cell to result in a number with one decimal place.
There you go!
Comments