Рет қаралды 130
How to Calculate Exact Age or Duration in Excel with DATEDIF Function
In this video, you will learn how to calculate the exact age or duration of a person or an event in years, months and days in Excel with the DATEDIF function.
The DATEDIF function is a built-in function in Excel that can be used to calculate the difference between two dates. The function takes three arguments:
The first argument is the start date.
The second argument is the end date.
The third argument is the unit of measurement.
The possible units of measurement are:
Y: Years
M: Months
D: Days
For example, the following formula will calculate the number of years between the current date and the date of birth:
Code snippet
=DATEDIF(TODAY(), "Birthday", "Y")
Use code with caution. Learn more
The following formula will calculate the number of months between the current date and the date of an event:
Code snippet
=DATEDIF(TODAY(), "Event Date", "M")
Use code with caution. Learn more
The following formula will calculate the number of days between the current date and the date of a deadline:
Code snippet
=DATEDIF(TODAY(), "Deadline Date", "D")
Use code with caution. Learn more
You can also use the DATEDIF function to calculate the exact age or duration of a person or an event in years, months and days. To do this, you will need to use three separate DATEDIF functions, one for each unit of measurement.
For example, the following formula will calculate the exact age of a person in years, months and days:
=DATEDIF(B2, TODAY(), "Y") & " Years, " & DATEDIF(B2, TODAY(), "M") & " Months, " & DATEDIF(B2, TODAY(), "D") & " Days"
Where B2 is the cell that contains the person's date of birth.