You are on page 1of 24

Use DATEDIF to Calculate Age in Excel

https://www.vertex42.com/blog/excel-formulas/calculate-age-in-excel.html

This workbook contains examples from the article "Use DATEDIF to Calculate Age in Excel," plus some extra
article. Regarding copyright and sharing, think of this file like a book. You may use the ideas and techniques a
you may not reproduce this worksheet or copy substantial portions from it, just as you would not do so with a b

Bookmarks: Calculate Age in Years


Calculate Age in Years, Months and Days
Calculate the Birth Date (subtract years, months and days from a date)
Calculate the Death Date (add years, months and days to a date)
Calculate Number of Months Between Two Dates
Calculate Number of Weeks Between Two Dates
Calculate Number of Days Between Two Dates
Subtract or Add a Month

DATEDIF Quick Reference


Syntax: =DATEDIF(start_date, end_date, interval)

Interval Returns
"y" Number of whole years between two dates
"m" Number of whole months between two dates
"d" Number of days between two dates
"ym" Remaining number of whole months (derived from "y" and "m")
"yd" Remaining number of days after ignoring complete years
"md" Remaining number of days after adding complete years and months to the start

• Returns #NUM! if start_date > end_date or the interval is not in this list.
• The start_date and end_date arguments can be text. DATEDIF uses DATEVALUE to convert
• Dates cannot be pre-1900.
• DATEDIF(start,end,"ym") is derived from DATEDIF(start,end,"m")-12*DATEDIF(start,end,"y")
• Using the "md" interval sometimes results in negative values, so it should be avoided.

If you discover any typos or errors in this document, please contact me via the email listed on my website. Tha
EXAMPLE FORMULAS

Calculate Age in Years


Method 1: Use DATEDIF to return the number of whole years between two d

Formula: =DATEDIF(birth_date,as_of_date,"y")

NOTE DATEDIF allows the start and end dates to be text. It uses the DATEVALUE function to conv
date values. The dates cannot be earlier than 1900.

TEMPLATE See this formula in action: Birth Calendar with Ages

Method 2: Calculate age in years without using DATEDIF

Formula: =YEAR(end)-YEAR(start)-( DATE(YEAR(end),


MONTH(start), DAY(start))>end )

NOTE To force an error when start > end, wrap the function with =IF(start>end,NA(),original_formu
count 2/29/2016 to 2/28/2017 as a whole year, you can add the following to this formula:
+IF( AND(MONTH(start)=2,DAY(start)=29,MONTH(end)=2,DAY(end)=28),1,0)
Method 3: Return a decimal number of years between two dates

Formula: =(end_date - start_date) / 365.2422

Formula: =(end_date - start_date) / 365.25

CAUTION Using INT or ROUNDDOWN with this method to return the number of whole years between
to incorrect results (e.g. 28-Feb-2013 to 28-Feb-2016). This method is not a valid substitute

Formula: =YEARFRAC(start_date,end_date)

CAUTION Note that this formula returns an incorrect result for 31-Jul-2012 to 30-Jul-2015. Using INT o
method to return the number of whole years between two dates will sometimes lead to incor
to 28-Feb-2016).

Calculate Age in Years, Months and Days


Method 1: Using DATEDIF to calculate years then months then days

Step 1: Calculate the number of complete years

Formula: years =DATEDIF(start_date, end_date, "y")

Step 2: Calculate the remaining number of complete months

Formula: months =DATEDIF(start_date, end_date, "ym")


Alternative: months =DATEDIF(start_date, end_date, "m") -
12*DATEDIF(start_date, end_date, "y")

WRONG: months =DATEDIF(start,DATE( YEAR(end) -


DATEDIF(start,end,"y"), MONTH(end), DAY(end)),"m")

Step 3: Calculate the remaining number of days after subtracting years and months from the end da

Using the "md" option for DATEDIF does not always give correct results.

WRONG: =DATEDIF(start_date, end_date, "md")

The "md" option uses the method of returning remaining days after Adding whole months to the Start Dat

WRONG: =end - DATE( YEAR(start), MONTH(start) +


DATEDIF(start,end,"m"), DAY(start))

The following formula is a suggested work around on the Microsoft support site, but it is not correct.
ref: https://support.office.com/en-us/article/DATEDIF-function-25dba1a4-2812-480b-84dd-8b32a451b35c

WRONG: =end_date-DATE( YEAR(end_date),


MONTH(end_date), 1)

The following formula correctly calculates remaining days after Subtracting whole months from the End D

CORRECT: days =DATE( YEAR(end), MONTH(end) -


DATEDIF(start,end,"m"), DAY(end)) - start

Step 4: Concatenate the results from steps 1-3


Formula: =years & "y " & months & "m " & days & "d"

Formula: =years&" years "&months&" months and "&days&"


days"

Step 5: Substitute formulas for steps 1-3 into the formula in step 4

Formula:
=DATEDIF(start, end, "y") & "y " & DATEDIF(start, end,
"ym") & "m " & (DATE(YEAR(end), MONTH(end) -
DATEDIF(start,end,"m"), DAY(end))-start) & "d"

Method 2: Calculate Age Using the 30-Day Month Method

This method is based on the procedure of subtracting dates and ages by hand using the technique of writing d
DD. In elementary school, you learned when subtracting how to borrow from the tens or hundreds place when
borrow from the MM place, we subtract one from MM and then add 30 days to DD. If we need to borrow from
one from the YYYY place and add 12 to MM.

YYYY MM DD
Death 1980 03 07
- Birth 1931 05 12
= Age 48 09 25

Step 1: Subtract the days in the DD place, borrowing 30 days from the MM place if needed.

Formula: days =DAY(end)+30*(DAY(end)<DAY(start))-DAY(start)

YYYY MM DD
Death 1980 02 37 (MM - 1, DD + 30)
- Birth 1931 05 12
= Age 25
NOTE Start with the day of the end date, then add 30 days if you need to borrow, then subtract the
may try to convert the result to a date, so change the number format back to General.

This formula is a valid alternative to DATEDIF(start,end,"y").

Step 2: Subtract the months in the MM place, borrowing 12 months from the YY place if needed.

Formula: months =MONTH(end) - MONTH(start) -


1*(DAY(end)<DAY(start)) + 12*((MONTH(end) -
1*(DAY(end)<DAY(start)))<MONTH(start))

YYYY MM DD
Death 1979 14 37 (YYYY - 1, MM + 12)
- Birth 1931 05 12
= Age 09 25

NOTE Start with the month of the end date, then subtract 1 if you had to borrow 30 days, then add
borrow from the years, then subtract the month of the start date.

This formula is a valid alternative to DATEDIF(start,end,"ym").

Step 3: Subtract the years in the YYYY place.

Formula: years =YEAR(end) - 1*( (MONTH(end)-


1*(DAY(end)<DAY(start))) < MONTH(start) ) -
YEAR(start)

YYYY MM DD
Death 1979 14 37
- Birth 1931 05 12
= Age 48 09 25

NOTE Start with the year of the end date, then subtract 1 if you had to borrow 12 months, then sub

Step 4: Concatenate the results from Steps 1-3

Although the result is a monster formula, it is possible to return the age in 48y 9m 25d within a single formula.

Formula: =YEAR(end) - 1*( (MONTH(end)-


1*(DAY(end)<DAY(start))) < MONTH(start) ) -
YEAR(start) & "y " & MONTH(end) - MONTH(start) -
1*(DAY(end)<DAY(start)) + 12*((MONTH(end) -
1*(DAY(end)<DAY(start)))<MONTH(start)) & "m " &
DAY(end)+30*(DAY(end)<DAY(start))-DAY(start) & "d"
=YEAR(end) - 1*( (MONTH(end)-
1*(DAY(end)<DAY(start))) < MONTH(start) ) -
YEAR(start) & "y " & MONTH(end) - MONTH(start) -
1*(DAY(end)<DAY(start)) + 12*((MONTH(end) -
1*(DAY(end)<DAY(start)))<MONTH(start)) & "m " &
DAY(end)+30*(DAY(end)<DAY(start))-DAY(start) & "d"

NOTE Method 2 results in a different age than Method 1 about 32% of the time, but only by 2 days
methods return the exact same number of years and months. It is only the number of days t

Method 3: Calculate Age Using the 30-Day Month Method and YYYYMMDD

If you enter dates as numeric values in the format YYYYMMDD, then you can use the 30-day method (also kn
subtract the dates and the result will be the age in YYYYMMDD format. After subtracting the start date from th
subtract 70, and if MM > 12, subtract 8800. You can then use a custom number format of 0"y "00"m "00"d" t
example, I've used the number format that does not display years or months if they are zero.

Formula: =end - start - IF(VALUE(RIGHT(end-start,2))>31,70) -


IF(VALUE(RIGHT(INT((end-start)/100),2))>12,8800)

NOTE To convert a date value (>1900) to a YYYYMMDD value, use


=VALUE(YEAR(date)&TEXT(MONTH(date),"00")&TEXT(DAY(date),"00"))

NOTE Use the following custom number format for YYYYMMDD age values to only display the yea
zero: [>9999]0"y "00"m "00"d";[>99]0"m "00"d";0"d"

NOTE For an age stored as a YYYYMMDD value, use =VALUE(RIGHT(yyyymmdd,2)) to return the
=VALUE(RIGHT(INT(yyyymmdd/100),2)) to return the months and use =INT(yyyymmdd/100

Method 4: Use the fact that one year = 365.2422 days and one month = 30.

This method calculates the years wrong about 0.15% of the time (occasionally when the day/month are the sa
The reason I am listing it here is only academic - because this is the only method I'm aware of that is complete
BOTH the original end date and the original birth date can be calculated from the years, months and days.
This method calculates the years wrong about 0.15% of the time (occasionally when the day/month are the sa
The reason I am listing it here is only academic - because this is the only method I'm aware of that is complete
BOTH the original end date and the original birth date can be calculated from the years, months and days.

Years: =INT((end-start)/365.2422)

Months: =INT(MOD(end-start,365.2422)/30.43685)

Days: =INT(MOD(end-start,30.43685))

Calculate the Original Start Date


Start Date: =ROUNDDOWN(end_date - years*365.2422 -
months*30.43685 - days,0)

Calculate the Original End Date


End Date: =ROUNDUP(start_date + years*365.2422 +
months*30.43685 + days,0)

Calculate the Birthdate if you Know the Death Date and Age
Use DATE to subtract a combination of years, months and days from an end date. Whether the answer is corr
methodology used to calculate the age.

Formula: =DATE(YEAR(end_date)-years,MONTH(end_date)-
months,DAY(end_date)-days)

Calculate the Death Date if you Know the Birthdate and Age
Use DATE to add a combination of years, months and days to a start date. Whether the answer is correct dep
used to calculate the age.

Formula: =DATE(YEAR(start_date)+years,MONTH(start_date)
+months,DAY(start_date)+days)
Calculate Number of Months Between Two Dates
Method 1: Using DATEDIF(start,end,"m")

Formula: =DATEDIF(start_date,end_date,"m")

NOTE Whole months and years are only counted if DAY(end_date) is greater than or equal to DAY
month or year. This means that DATEDIF returns 0 months between 1/31/2016 and 2/28/20
2/29/2016 and 2/28/2017, even though all these dates are the end of the month. DATEDIF r
1/1/2000 and 1/31/2000 because the dates are in the same month.

Method 2: Alternative to DATEDIF

Formula: =12*(YEAR(end) - YEAR(start)) + MONTH(end)-


MONTH(start) - (DAY(end) < DAY(start))

Method 3: Return Whole Months, Counting End-of-Month to End-of-Month a

Formula: =(YEAR(end) - YEAR(start))*12 + MONTH(end)-


MONTH(start) + IF( AND(end=EOMONTH(end,0),
start=EOMONTH(start,0)), 0, IF( DAY(end) >=
DAY(start),0,-1) )

NOTE If both dates are the end of the month, then you may want to treat the difference between th
formula handles that situation. This formula may be useful in situations involving bills or pay
always at the end of the month.
Calculate Number of Weeks Between Two Dates

Formula: =INT( (end_date - start_date) / 7 )

NOTE To return the decimal number of weeks, use =(end_date-start_date)/7.

Calculate Number of Days Between Two Dates

Formula: =(end_date - start_date)

Formula: =DATEDIF(start_date,end_date,"d")

Formula: =DAYS(end_date,start_date)

NOTE Using DATEDIF or DAYS allows the start_date and end_date to be text instead of date valu
than the year 1900.

Subtract or Add a Month


There are many methods for subtracting or adding months. The method you choose should depend on how yo
months have different numbers of days. In each of these formulas, if you choose a negative number of months
the date, while a positive number of months will be added.

Formula: = date_value + 30 * months

Formula: =EDATE(date, months)

Formula: =EOMONTH(date, months)


Formula: =DATE(YEAR(date), MONTH(date)+months,
DAY(date))

TEMPLATE See EDATE in action: Fiscal Year Calendar

REFERENCES

ARTICLE support.office.com : DATEDIF Function

ARTICLE support.office.com : EDATE Function

ARTICLE support.office.com : Calculate the difference between two dates


© 2017 Vertex42 LLC

Age in Excel," plus some extra examples not included in the


use the ideas and techniques and formulas explained here, but
as you would not do so with a book. Thank you. - Jon Wittwer

m "y" and "m")

e years and months to the start date

F uses DATEVALUE to convert text-based dates.

m")-12*DATEDIF(start,end,"y")
so it should be avoided.

email listed on my website. Thank you.


e years between two dates

birth_date as_of_date Result


17-Aug-1968 17-Aug-2017 49
17-Aug-2017 17-Aug-1968 Err:502 start > end
29-Feb-2016 28-Feb-2017 0 start = leap day
1-Jan-2000 31-Dec-2000 0
2-Jul-1968 2-Jul-2015 47
28-Feb-2013 28-Feb-2016 3
31-Jul-2012 30-Jul-2015 2

e DATEVALUE function to convert the text-based dates to

birth_date as_of_date Result


17-Aug-1968 17-Aug-2017 49
17-Aug-2017 17-Aug-1968 -49 start > end
29-Feb-2016 28-Feb-2017 0 start = leap day
1-Jan-2000 31-Dec-2000 0
2-Jul-1968 2-Jul-2015 47
28-Feb-2013 28-Feb-2016 3
31-Jul-2012 30-Jul-2015 2

F(start>end,NA(),original_formula). If it is important enough to


he following to this formula:
AY(end)=28),1,0)
two dates

start_date end_date Result


28-Feb-2013 28-Feb-2016 2.9980106351
2-Jul-1968 2-Jul-2015 46.9989502856

start_date end_date Result


28-Feb-2013 28-Feb-2016 2.9979466119
2-Jul-1968 2-Jul-2015 46.9979466119

umber of whole years between two dates will sometimes lead


method is not a valid substitute for DATEDIF(start,end,"y").

start_date end_date Result


28-Feb-2013 28-Feb-2016 2.9944444444
2-Jul-1968 2-Jul-2015 47
31-Jul-2012 30-Jul-2015 3

012 to 30-Jul-2015. Using INT or ROUNDDOWN with this


tes will sometimes lead to incorrect results (e.g. 28-Feb-2013

nths then days

Start Date End Date years


31-Mar-2014 1-Mar-2020 5

Start Date End Date months


31-Mar-2014 1-Mar-2020 11
Start Date End Date Result
31-May-2008 29-Feb-2016 8

Start Date End Date months


31-May-2008 29-Feb-2016 9

and months from the end date.

Start Date End Date Result


31-Mar-2014 1-Mar-2020 -1
31-Jan-2017 1-Mar-2017 -2

whole months to the Start Date.

Start Date End Date Result


31-Mar-2014 1-Mar-2020 -1
31-Jan-2017 1-Mar-2017 -2

site, but it is not correct.


12-480b-84dd-8b32a451b35c

Start Date End Date Result


31-Jan-2016 31-Jan-2017 30 should be 0
18-Jun-2010 18-May-2016 17 should be 0

whole months from the End Date.

Start Date End Date days


31-Mar-2014 1-Mar-2020 1
31-Jan-2017 1-Mar-2017 1
31-Jan-2016 31-Jan-2017 0
18-Jun-2010 18-May-2016 0

Result
5y 11m 1d

5 years 11 months and 1 days

Start Date End Date Result


31-Mar-2014 1-Mar-2020 5y 11m 1d
29-Feb-2016 28-Feb-2018 1y 11m 28d
28-Feb-2003 29-Feb-2004 1y 0m 1d
12-May-1931 7-Mar-1980 48y 9m 26d

using the technique of writing dates and ages as YYYY MM


e tens or hundreds place when needed. Here, if we need to
DD. If we need to borrow from the YYYY place, we subtract

Start End Years Months Days


1931-05-12 1980-03-07 48 9 25
2014-03-31 2020-03-01 5 11 0
2016-02-29 2018-02-28 1 11 29
2003-02-28 2004-02-29 1 0 1
2003-01-15 2004-01-15 1 0 0

MM place if needed.

Start End Years Months Days


1931-05-12 1980-03-07 ----- ----- 25
eed to borrow, then subtract the day of the start date. Excel
r format back to General.

m the YY place if needed.

Start End Years Months Days


1931-05-12 1980-03-07 ----- 9 -----

ad to borrow 30 days, then add 12 months if you need to


ate.

Start End Years Months Days


1931-05-12 1980-03-07 48 ----- -----

to borrow 12 months, then subtract the year of the start date.

9m 25d within a single formula.

Start End Years


1931-05-12 1980-03-07 48y 9m 25d
2014-03-31 2020-03-01 5y 11m 0d
2016-02-29 2018-02-28 1y 11m 29d
2003-02-28 2004-02-29 1y 0m 1d
2003-04-01 2005-03-31 1y 11m 30d
2004-09-20 2005-03-15 0y 5m 25d
2004-09-15 2004-09-25 0y 0m 10d

of the time, but only by 2 days at most. Turns out that both
. It is only the number of days that may be different.

hod and YYYYMMDD Date Values

use the 30-day method (also known as the 8870 technique) to


ubtracting the start date from the end date, if DD > 31, then
r format of 0"y "00"m "00"d" to display the age. In this
they are zero.

Start End Age start-end Years Months


19310512 19800307 48y 09m 25d 489795 48 9
20160229 20180228 1y 11m 29d 19999 1 11
20040920 20050315 5m 25d 9395 0 5
20040915 20040925 10d 10 0 0

Y(date),"00"))

e values to only display the years and months if they are not

GHT(yyyymmdd,2)) to return the days, use


s and use =INT(yyyymmdd/10000) to return the years.

and one month = 30.43685 days

when the day/month are the same for the start and end dates).
od I'm aware of that is completely reversible - meaning that
he years, months and days.
Start Date End Date Years Months Days
31-Mar-2014 1-Mar-2020 5 11 0
29-Feb-2016 28-Feb-2018 1 11 29
28-Feb-2013 28-Feb-2016 2 11 29

End Date Years Months Days Start Date


1-Mar-2020 5 11 0 31-Mar-2014
28-Feb-2018 1 11 29 29-Feb-2016
28-Feb-2016 2 11 29 28-Feb-2013

Start Date Years Months Days Start Date


31-Mar-2014 5 11 0 1-Mar-2020
29-Feb-2016 1 11 29 28-Feb-2018
28-Feb-2013 2 11 29 28-Feb-2016

ath Date and Age


ate. Whether the answer is correct depends upon the

End Date Years Months Days Start Date


6-Jan-2017 49 5 26 11-Jul-1967

irthdate and Age


ether the answer is correct depends upon the methodology

Start Date Years Months Days End Date


11-Jul-1967 49 5 26 6-Jan-2017
Dates

start_date end_date Months


31-Jan-2016 31-Jan-2017 12
31-Jan-2017 28-Feb-2017 0
31-Jan-2017 1-Mar-2017 1
29-Feb-2016 28-Feb-2017 11
1-Jan-2000 31-Jan-2000 0

is greater than or equal to DAY(start_date) for the following


etween 1/31/2016 and 2/28/2016 and 11 months between
e end of the month. DATEDIF returns 0 months between
month.

start end Months


31-Jan-2016 31-Jan-2017 12
31-Jan-2017 28-Feb-2017 0
31-Jan-2017 1-Mar-2017 1
29-Feb-2016 28-Feb-2017 11

nth to End-of-Month as a Whole Month

start end Months


31-Jan-2016 31-Jan-2017 12
31-Jan-2017 28-Feb-2017 1
29-Feb-2016 28-Feb-2017 12
30-Jan-2017 28-Feb-2017 0

treat the difference between them as whole months. This


situations involving bills or payments or pay periods that are
start_date end_date Weeks
28-Feb-2013 28-Feb-2016 156
2-Jul-1968 2-Jul-2015 2452

t_date)/7.

start_date end_date Days


28-Feb-2013 28-Feb-2016 1095

28-Feb-2013 28-Feb-2016 1095

28-Feb-2013 28-Feb-2016 1095

e to be text instead of date values. The dates cannot be earlier

oose should depend on how you want to handle the fact that
e a negative number of months, they will be subtracted from

date_value months Days


31-Mar-2017 -1 1-Mar-2017
31-Mar-2017 1 30-Apr-2017

31-Mar-2017 -1 28-Feb-2017
31-Mar-2017 1 30-Apr-2017

31-Mar-2017 -1 28-Feb-2017
31-Mar-2017 1 30-Apr-2017
31-Mar-2017 -1 3-Mar-2017
31-Mar-2017 1 1-May-2017
Days
25
29
25
10
Calculate Age in Excel - Examples

By Vertex42.com
https://www.vertex42.com/blog/excel-formulas/use-datedif-to-calculate-age-in-excel.html

© 2017 Vertex42 LLC

This spreadsheet, including all worksheets and associated content is a


copyrighted work under the United States and other copyright laws.

Do not submit copies or modifications of this file to any website or online


template gallery.

Please review the following license agreement to learn how you may or may
not use this file. Thank you.

https://www.vertex42.com/licensing/EULA_privateuse.html

You might also like