# DateDiff()

Returns the difference between two dates or times.

## Availability

<table>
  <tr>
    <td>Marketing Cloud Engagement</td>
    <td>✅ Yes</td>
  </tr>
  <tr>
    <td>Marketing Cloud Next</td>
    <td>✅ Yes</td>
  </tr>
</table>

This function became available in Marketing Cloud Next during the Summer ’26 release (API version 67.0).

## Syntax

```
DateDiff(startDate, endDate, unitOfDifference)
```

The `DateDiff()` function has three parameters.

- `startDate` (date): Required. The starting date for the comparison.
- `endDate` (date): Required. The end date for the comparison. The function subtracts the `startDate` from the `endDate`.
- `unitOfDifference` (string): Required. The unit of time difference to return. Accepted values: `Y` (years), `M` (months), `D` (days), `H` (hours), and `MI` (minutes).

## Usage

This example adds one day to the current timestamp, and then uses the `DateDiff()` function to calculate the number of minutes until the new date. The example assumes that the current timestamp is 2024-08-04T13:41:23Z.

```
%%[
  Var @now, @later, @diff
  Set @now = Now()
  Set @later = DateAdd(@now, '1','D')

  Set @diff = DateDiff(@now, @later, "MI")
]%%
<p>There are %%=v(@diff)=%% minutes until %%=v(@later)=%%.</p>
```

The function outputs the number of minutes until 1 day from the current date.

```
There are 1440 minutes until 8/5/2024 1:41:23 PM.
```
