> ## Documentation Index
> Fetch the complete documentation index at: https://help.dingtalk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Using DATEDIF

> 📌 More functions: see the formula function reference.

> 📌 More functions: see the [Formula function reference](/aitable/formulas/function-reference).

**DATEDIF** computes the difference between two dates in AI Table — return the result in years, months, or days. Fits scenarios that need precise date math.

# 1 Basics

### Syntax

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DATEDIF([start_date], [end_date], unit)
```

* **start\_date**: starting date.
* **end\_date**: ending date.
* **unit**: time unit for the return value:
  * **"Y"**: full years between the dates.
  * **"M"**: full months between the dates.
  * **"D"**: days between the dates.
  * **"MD"**: ignore year and month — days only.
  * **"YM"**: ignore year — months only.
  * **"YD"**: ignore year — days only.

### Examples

Two date fields: \[Start date], \[End date].

#### Example 1: full years between two dates

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
=DATEDIF([Start date], [End date], "Y")
```

#### Example 2: days between two dates

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
=DATEDIF([Start date], [End date], "D")
```

# 2 Scenario examples

### 2.1 Cycle time

Compute the gap between \[Dispatched at] and \[Executed at] to gauge the store's response speed.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DATEDIF([Dispatched at],[Executed at],"D")
```

<video src="https://cloud.video.taobao.com/vod/8Bmmt2YrfYiDb7r3uQWqmT8rgxftNcR9SenjSxgb-6Q.mp4" controls width="100%" />

### 2.2 Days remaining

Compute days between \[Check date] and today for planning.

```excel formula theme={"theme":{"light":"github-light","dark":"github-dark"}}
DATEDIF(TODAY(),[Check date],"D")
```

<video src="https://cloud.video.taobao.com/vod/bq87Rc066RHX4kY7G1-Mipe2428hZKxO-Iiqlm-q49s.mp4" controls width="100%" />

# 3 FAQ

* **Q**: DATEDIF returns "#ERROR!" — what's wrong?

  **A**: Check whether end date is earlier than start date. If so, computation errors or returns negative values.
