DATEDIF
Calculates the number of days, months, or years between two dates
Syntax
DATEDIF(start_date, end_date, unit)
Arguments
| Argument |
Description |
Required |
start_date |
A date that represents the first, or starting date of the period |
Required |
end_date |
A date that represents the last, or ending date of the period |
Required |
unit |
The type of information you want returned: "Y", "M", "D", "MD", "YM", "YD" |
Required |
Examples
Calculate years between two dates
=DATEDIF(A1, A2, "Y")
Result ⇒
4
Calculate months between two dates
=DATEDIF(A1, A2, "M")
Result ⇒
3
Calculate days between two dates
=DATEDIF(A1, A2, "D")
Result ⇒
14
Related Functions
Other Date/Time functions:
- DATE - Constructs a date from year, month, and day values.
- DATEONLY - Extracts the date component from a datetime value, removing the time portion. The result is in workbook time zone.
- DAY - Returns the day of the month from a date value.
- DAYOFWEEK - Returns the day of the week as a text string
- DAYS - Returns the number of days between two dates
- EDATE - Returns a date on the same day of the month, n months in the past or future.
- EOMONTH - Returns last day of a month as a serial number after adding a specified number of months before or after another date.
- HOUR - Returns the hour component of a specific time as a number between 0-23.
- ISOWEEKNUM - Returns the ISO-8601 week number (1–53) of the year for a given date.
- MINUTE - Returns the minutes of a time value
- MONTH - Returns the month from a date value (1-12).
- NETWORKDAYS - Returns the number of work days between two dates, excluding saturday and sunday.
- NOW - Returns the current date and time as a date value in UTC.
- SECOND - Returns the seconds of a time value
- TIME - Returns the created time with individual hour, minute and second components.
- TIMEVALUE - Returns the decimal number of the time represented by a string. The decimal number is a value ranging from 0 (inclusive) to 1 (exclusive).
- TODAY - Returns the current date as a date value in UTC with time stripped.
- WEEKDAY - Returns the number that corresponds to the week of provided date.
- WEEKNUM - Returns the week number of a specific date
- WORKDAY - Returns the date that is the specified number of working days before or after the start date.
- YEAR - Returns the year from a date value.
- YEARFRAC - Calculates the fraction of the year represented by the number of whole days between two dates
← Back to Formula Reference