---
schema_version: "1"
id: d242631b3b3188cd640a492dfc9701333daae6c5e63f6a17c0d9f278346529d6
title: DateDiff()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/ampscript/references/date-time/mc-ampscript-reference-date-time-date-diff.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-date-time/mc-ampscript-reference-date-time-date-diff.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 46ea5a96aa6cd8c6d4b4e7fff10c9929fad1958282cc1d77bfefb4927e33e4db
products:
  - AMPscript for Marketing Cloud
  - Marketing Cloud
---
# 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.
```
