DateDiff()

Returns the difference between two dates or times.

Availability 

Marketing Cloud Engagement ✅ Yes
Marketing Cloud Next ✅ Yes

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

Syntax 

1DateDiff(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.

1%%[
2  Var @now, @later, @diff
3  Set @now = Now()
4  Set @later = DateAdd(@now, '1','D')
5
6  Set @diff = DateDiff(@now, @later, "MI")
7]%%
8<p>There are %%=v(@diff)=%% minutes until %%=v(@later)=%%.</p>

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

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