# DATEDIFF() Function

### Description

Returns the difference between two dates or timestamps

**Aliases:** `DATE_DIFF`

### Syntax

```sql
DATEDIFF(unit, start, end)
```

### Parameters

| Parameter | Description | Data Type | Required |
| --- | --- | --- | --- |
| _unit_ | Date part for the difference (for example day, week, month, year) | String | Yes |
| _start_ | Starting date or timestamp | Date or timestamp | Yes |
| _end_ | Ending date or timestamp | Date or timestamp | Yes |

#### Accepted datepart values

| Datepart Name | Datepart Abbreviation |
| --- | --- |
| year | yy, yyyy |
| quarter | qq, q |
| month | mm, m |
| dayofyear | dy, y |
| day | dd, d |
| week | wk, ww |
| weekday | dw, w |
| hour | hh |
| minute | mi, n |
| second | ss, s |
| millisecond | ms |
| microsecond | mcs |
| nanosecond | ns |

#### Notes

-   Public Transformations SQL spelling is `DATEDIFF(...)`. `DATE_DIFF(...)` is also accepted by the parser.

### Example

```sql
SELECT
    DATEDIFF('day', start_date, end_date)
FROM
    rippling.employee.Employee
LIMIT
    5;
```

Source: https://developer.rippling.com/documentation/rippling-platform/transformations/sql-reference/datediff

> For the complete documentation index, see [llms.txt](https://developer.rippling.com/llms.txt). Public pages have a Markdown version at the same URL with .md added.
