DATEDIF function
Calculates the number of days, months, or years between two dates. This function is useful in formulas where you need to calculate an age.
Syntax
DATEDIF(start_date, end_date, Unit)Square brackets indicate optional arguments.
Arguments
| Argument | Required | Meaning |
|---|---|---|
| start_date | Yes | A date that represents the first, or starting date of a given period. Dates may be entered as text strings within quotation marks (for example, "2001/1/30"), as serial numbers (for example, 36921, which represents January 30, 2001, if you're using the 1900 date system), or as the results of other formulas or functions (for example, DATEVALUE("2001/1/30"))."2001-6-1" |
| end_date | Yes | A date that represents the last, or ending, date of the period."2002-8-15" |
| Unit | Yes | The type of information that you want returned, where: Unit****Returns " Y "The number of complete years in the period." M "The number of complete months in the period." D "The number of days in the period." MD "The difference between the days in start_date and end_date. The months and years of the dates are ignored. Important: We don't recommend using the "MD" argument, as there are known limitations with it. See the known issues section below." YM "The difference between the months in start_date and end_date. The days and years of the dates are ignored" YD "The difference between the days of start_date and end_date. The years of the dates are ignored."D" |
Try DATEDIF
Count complete years between dates
=DATEDIF(D2,DATE(2027,10,1),"y")Count complete years between dates. The result is checked against a separately authored expected value for the supplied table. You can edit the data to explore the rule.
Inspect the current formula
Read its written arguments or observe actual operation values in a separate local calculation. This action neither applies a draft nor grades an answer.
Read the formula, one argument at a time
Explore the written function calls and their inputs. The calculation result belongs to the complete formula.
DATEDIF · top-level call
=DATEDIF(D2,DATE(2027,10,1),"y")1 / 3 · start_date
A date that represents the first, or starting date of a given period. Dates may be entered as text strings within quotation marks (for example, "2001/1/30"), as serial numbers (for example, 36921, which represents January 30, 2001, if you're using the 1900 date system), or as the results of other formulas or functions (for example, DATEVALUE("2001/1/30")).
DATEDIF reference ↗Follow the cells behind a result
Read explicit local references and helper formulas using a separate calculation. Your draft stays in this field; the worksheet and practice checks do not change.
The worksheet runs locally. Published checks apply to the supplied example only. Native Excel and Google Sheets compatibility remain unverified.
Practice a complete task
Reference and compatibility
Univer 1.0.4 / Apache-2.0. Calculation checks cover the supplied examples only. The browser worksheet does not implement every Excel feature, external service or connected data type.