# DATEDIF Function

> Calculate the complete years, months or days between two dates with DATEDIF in TX Sheet Control: the units Y, M, D, MD, YM and YD and the #NUM! error.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Function
- **Path:** TX Sheet Control > API Reference > Formula Functions > DATEDIF Function
- **248 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/datedif/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/datedif/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/datedif/llms-full.txt

---

Return the number of complete years, months or days between two dates. `start_date` and `end_date` are date serial numbers or dates in text form, and `unit` is the kind of difference, in uppercase or lowercase: "Y" (years), "M" (months), "D" (days), "MD" (days, ignoring months and years), "YM" (months, ignoring years) or "YD" (days, ignoring years). A start date after the end date, or another unit, returns `#NUM!`.

### Syntax

```text
DATEDIF(start_date, end_date, unit)
```

Category: Date & Time. Minimum arguments: 3. Maximum arguments: 3.

Available for supported offline calculation.

### Examples

```text
=DATEDIF(DATE(2020,1,1),DATE(2026,1,1),"Y")
```

The formula returns 6, the complete years from January 1, 2020, to January 1, 2026.

Cell and range examples require appropriate input values in the referenced cells. Handle invalid arguments, formula errors and array and spill constraints.

### See Also

- [Formulas](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/formulas/llms-full.txt)
- [Custom Functions and Formula Data](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/custom-functions/llms-full.txt)

---

## Nearby

- **Previous:** [DATE Function](https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/date/llms-full.txt)
- **Next:** [DATEVALUE Function](https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/datevalue/llms-full.txt)
