Runtime verified Differs from official docs Test scripts included

Syntax

DateAdd(date, amountToAdd, unitToAdd)  →  date
3 arguments — exactly

Parameters

Name Type Required Description
date string | date Yes The date to adjust, either a real date value or a parseable date string
amountToAdd string | number Yes The number of intervals; negative subtracts. A decimal is accepted, and 1.5 days added one day
unitToAdd string Yes One of Y, M, D, H, MI or S. The first five work in any capitalisation

Example

%%=DateAdd("2026-01-15", 7, "D")=%%

Renders 2026-01-22T00:00:00.

Wrap the result in Format when the output needs a particular shape:

%%=Format(DateAdd("2026-03-04 13:52:07", 1, "D"), "yyyy-MM-dd HH:mm:ss")=%%

Renders 2026-03-05 13:52:07.

Return value

date — the adjusted date. Printed on its own it comes out in ISO form, date and time joined by a T with no time zone suffix: DateAdd("2026-03-04 13:52:07", -3, "H") gives 2026-03-04T10:52:07.

The value goes straight into other date functions. DateAdd(DateAdd("2026-03-04 13:52:07", 1, "D"), 1, "D") lands on March 6, and Format and FormatDate accept it directly.

Behaviour

Five units move one field each. From 2026-03-04 13:52:07, adding one Y, M, D, H or MI gave 2027-03-04 13:52:07, 2026-04-04 13:52:07, 2026-03-05 13:52:07, 2026-03-04 14:52:07 and 2026-03-04 13:53:07 (formatted with yyyy-MM-dd HH:mm:ss). Lower-case and mixed-case spellings (y, m, d, h, mi, Mi, mI) gave the same results.

Seconds work too. DateAdd("2026-03-04 13:52:07", 30, "S") renders 2026-03-04T13:52:37.

Other unit tokens break the render. An email with a weeks unit W, a milliseconds unit MS, the word day or an unknown token ZZ saves and publishes, but its preview fails. Stick to the six units above.

The amount is flexible. A negative amount subtracts, zero leaves the date unchanged, and 400 days rolls into the next year (2027-04-08). A numeric string such as "1" or "-1" works like the number. A decimal does not fail: 1.5 days gave the same result as 1. A word such as "two" makes the preview fail.

Date strings and date values both work. ISO (2026-01-15), US slash (1/1/2026) and spelled-out (1 January 2026) strings parse, and Now() is accepted directly. A string that is not a date, such as not a date at all, makes the preview fail.

Exactly three arguments. An email that calls DateAdd with two or with four arguments cannot be saved: the content API answers HTTP 400 with “The AMPscript syntax isn’t valid”.

Month arithmetic clamps to the month end

Call (formatted yyyy-MM-dd HH:mm:ss) Renders
DateAdd("2026-01-31 13:52:07", 1, "M") 2026-02-28 13:52:07
DateAdd("2026-01-31 13:52:07", 2, "M") 2026-03-31 13:52:07
DateAdd(DateAdd("2026-01-31 13:52:07", 1, "M"), -1, "M") 2026-01-28 13:52:07
DateAdd("2026-03-31 09:00:00", -1, "M") 2026-02-28 09:00:00
DateAdd("2028-02-29 09:00:00", 1, "Y") 2029-02-28 09:00:00

A month added to the 31st lands on the last day of a shorter month. Going forward one month and back one month does not return to the start: the 31st becomes the 28th.

Show Next test script
<!-- Marketing Cloud Next test script for DateAdd. Paste it into the HTML component of a
     Next email and open the preview. Each line prints the result Next gave when the call
     was rendered on its own (expect) next to the result of this run (got).
     Assembled from single-call test emails (dates on the page); it has not been
     run as one email. Calls that make Next fail are listed separately. -->
<p>c1 expect=[2026-01-22T00:00:00] got=[%%=DateAdd("2026-01-15",7,"D")=%%]</p>
<p>c2 expect=[2026-02-15T00:00:00] got=[%%=DateAdd("2026-01-15",1,"M")=%%]</p>
<p>c3 expect=[2026-01-02T00:00:00] got=[%%=DateAdd("2026-01-01", 1, "D")=%%]</p>
<p>c4 expect=[2026-03-04T10:52:07] got=[%%=DateAdd("2026-03-04 13:52:07", -3, "H")=%%]</p>
<p>c5 expect=[2027-03-04 13:52:07|2026-04-04 13:52:07|2026-03-05 13:52:07|2026-03-04 14:52:07|2026-03-04 13:53:07] got=[%%=Format(DateAdd("2026-03-04 13:52:07",1,"Y"),"yyyy-MM-dd HH:mm:ss")=%%|%%=Format(DateAdd("2026-03-04 13:52:07",1,"M"),"yyyy-MM-dd HH:mm:ss")=%%|%%=Format(DateAdd("2026-03-04 13:52:07",1,"D"),"yyyy-MM-dd HH:mm:ss")=%%|%%=Format(DateAdd("2026-03-04 13:52:07",1,"H"),"yyyy-MM-dd HH:mm:ss")=%%|%%=Format(DateAdd("2026-03-04 13:52:07",1,"MI"),"yyyy-MM-dd HH:mm:ss")=%%]</p>
<p>c6 expect=[2027-03-04 13:52:07|2026-04-04 13:52:07|2026-03-05 13:52:07|2026-03-04 14:52:07|2026-03-04 13:53:07|2026-03-04 13:53:07|2026-03-04 13:53:07] got=[%%=Format(DateAdd("2026-03-04 13:52:07",1,"y"),"yyyy-MM-dd HH:mm:ss")=%%|%%=Format(DateAdd("2026-03-04 13:52:07",1,"m"),"yyyy-MM-dd HH:mm:ss")=%%|%%=Format(DateAdd("2026-03-04 13:52:07",1,"d"),"yyyy-MM-dd HH:mm:ss")=%%|%%=Format(DateAdd("2026-03-04 13:52:07",1,"h"),"yyyy-MM-dd HH:mm:ss")=%%|%%=Format(DateAdd("2026-03-04 13:52:07",1,"mi"),"yyyy-MM-dd HH:mm:ss")=%%|%%=Format(DateAdd("2026-03-04 13:52:07",1,"Mi"),"yyyy-MM-dd HH:mm:ss")=%%|%%=Format(DateAdd("2026-03-04 13:52:07",1,"mI"),"yyyy-MM-dd HH:mm:ss")=%%]</p>
<p>c7 expect=[2026-03-03 13:52:07|2026-03-04 13:52:07|2027-04-08 13:52:07] got=[%%=Format(DateAdd("2026-03-04 13:52:07",-1,"D"),"yyyy-MM-dd HH:mm:ss")=%%|%%=Format(DateAdd("2026-03-04 13:52:07",0,"D"),"yyyy-MM-dd HH:mm:ss")=%%|%%=Format(DateAdd("2026-03-04 13:52:07",400,"D"),"yyyy-MM-dd HH:mm:ss")=%%]</p>
<p>c8 expect=[2026-03-05 13:52:07|2026-03-03 13:52:07] got=[%%=Format(DateAdd("2026-03-04 13:52:07","1","D"),"yyyy-MM-dd HH:mm:ss")=%%|%%=Format(DateAdd("2026-03-04 13:52:07","-1","D"),"yyyy-MM-dd HH:mm:ss")=%%]</p>
<p>c9 expect=[2026-01-02 00:00:00|2026-01-02 00:00:00] got=[%%=Format(DateAdd("1/1/2026",1,"D"),"yyyy-MM-dd HH:mm:ss")=%%|%%=Format(DateAdd("1 January 2026",1,"D"),"yyyy-MM-dd HH:mm:ss")=%%]</p>
<p>c10 expect=[2026|2026-03-06 13:52:07] got=[%%=FormatDate(DateAdd(Now(),0,"D"),"yyyy")=%%|%%=Format(DateAdd(DateAdd("2026-03-04 13:52:07",1,"D"),1,"D"),"yyyy-MM-dd HH:mm:ss")=%%]</p>
<p>c11 expect=[2026-02-28 13:52:07|2026-01-28 13:52:07|2026-03-31 13:52:07|2026-02-28 09:00:00|2029-02-28 09:00:00] got=[%%=Format(DateAdd("2026-01-31 13:52:07",1,"M"),"yyyy-MM-dd HH:mm:ss")=%%|%%=Format(DateAdd(DateAdd("2026-01-31 13:52:07",1,"M"),-1,"M"),"yyyy-MM-dd HH:mm:ss")=%%|%%=Format(DateAdd("2026-01-31 13:52:07",2,"M"),"yyyy-MM-dd HH:mm:ss")=%%|%%=Format(DateAdd("2026-03-31 09:00:00",-1,"M"),"yyyy-MM-dd HH:mm:ss")=%%|%%=Format(DateAdd("2028-02-29 09:00:00",1,"Y"),"yyyy-MM-dd HH:mm:ss")=%%]</p>
<p>c12 expect=[2026-03-04T13:52:37] got=[%%=DateAdd("2026-03-04 13:52:07",30,"S")=%%]</p>
<p>c13 expect=[2026-03-05T13:52:07] got=[%%=DateAdd("2026-03-04 13:52:07",1.5,"D")=%%]</p>

Show calls that fail in Next (one email each)
<!-- Run each call below in its own Next email: one of them in a combined email
     would stop the whole preview or block the save. -->

<!-- email 1: expect that the email saves, but the preview never shows the new version (no fresh render) -->
%%=DateAdd("2026-03-04 13:52:07",1,"W")=%%

<!-- email 2: expect that the email saves, but the preview fails (HTTP 500) -->
%%=DateAdd("2026-03-04 13:52:07",1,"MS")=%%

<!-- email 3: expect that the email saves, but the preview never shows the new version (no fresh render) -->
%%=DateAdd("2026-03-04 13:52:07",1,"day")=%%

<!-- email 4: expect that the email saves, but the preview fails (HTTP 500) -->
%%=DateAdd("2026-03-04 13:52:07",1,"ZZ")=%%

<!-- email 5: expect that the email saves, but the preview fails (HTTP 500) -->
%%=DateAdd("2026-03-04 13:52:07","two","D")=%%

<!-- email 6: expect that the email saves, but the preview fails (HTTP 500) -->
%%=DateAdd("not a date at all",1,"D")=%%

<!-- email 7: expect that the save is rejected (HTTP 400) -->
%%=DateAdd("2026-03-04 13:52:07",1)=%%

<!-- email 8: expect that the save is rejected (HTTP 400) -->
%%=DateAdd("2026-03-04 13:52:07",1,"D","extra")=%%

Differs from official docs

  • The result prints in ISO form. The reference’s example shows a DateAdd value printed as a US date with AM/PM. In Next, DateAdd("2026-01-15", 7, "D") printed 2026-01-22T00:00:00. Card
  • Fractional amounts are cut silently. The reference does not say that a decimal amount loses its fraction. In Next, adding 1.5 days added exactly one day, with no error. Card

Availability & differences

PlatformAvailable
Marketing Cloud EngagementYes
Marketing Cloud NextYes, from API 67.0

See also