You calculate age between two dates in Google Sheets using the DATEDIF
function.
Here's how to use it:
Syntax:
=DATEDIF(start_date, end_date, unit)
Explanation:
start_date
: The date the period begins (e.g., birth date).end_date
: The date the period ends (e.g., today's date).unit
: A code that specifies the unit of time you want to calculate.
Common Units:
Unit | Description | Example Output |
---|---|---|
"Y" | Years completed | 25 |
"M" | Months completed | 300 |
"D" | Days between dates | 9131 |
"YD" | Days, ignoring years | 0 |
"MD" | Days, ignoring months and years | 0 |
"YM" | Months, ignoring years | 0 |
Example:
Let's say the birth date is in cell A1 (e.g., 1999-10-25) and you want to calculate the age as of today. You would use the following formula:
=DATEDIF(A1, TODAY(), "Y")
This formula calculates the number of whole years between the date in cell A1 and today's date.
Important Considerations:
-
TODAY()
Function: TheTODAY()
function automatically updates to the current date. You can also use a specific date instead ofTODAY()
if needed. For example:=DATEDIF(A1, "2024-10-25", "Y")
. -
DATEDIF
Quirks:DATEDIF
isn't officially documented by Google, but it functions reliably. -
Error Handling: Ensure both the start and end dates are valid date formats for accurate results.
-
Alternative Calculation for specific date: You can use cell referencing like
=DATEDIF(A1, B1, "Y")
where A1 and B1 contains start and end dates respectively.