DATEDIF Function in Google Sheets

Calculates the difference between two dates in specified units.

DATEDIF Function

The DATEDIF function calculates the difference between two dates in specified units.

Syntax

DATEDIF(start_date, end_date, unit)
  • start_date: The start date of the period.
  • end_date: The end date of the period.
  • unit: The unit in which to return the difference (e.g., “Y” for years, “M” for months, “D” for days).

Examples

  1. Basic Example

Calculate the number of days between January 1, 2024, and August 14, 2024:

=DATEDIF(DATE(2024, 1, 1), DATE(2024, 8, 14), "D")
  1. Calculate Years

Find the number of years between two dates:

=DATEDIF(DATE(2000, 1, 1), DATE(2024, 1, 1), "Y")

Notes

  • This function is useful for calculating age or the duration between two dates.
  • YEARFRAC: Returns the fraction of the year represented by the number of whole days between two dates.