Handlebars dateAdd
Handlebars dateAdd: moves a date forward or back by a number of time units.
Next
Runtime verified
Differs from official docs
Test scripts included
Moves a date forward or back by a number of time units.
Syntax
{{dateAdd date number interval}}
Returns string.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
date |
string | Yes | The starting date. |
number |
integer | Yes | How many units to add. A negative number moves the date back. |
interval |
string | Yes | Time unit: Y, M, D, H, MI, or S. |
Example
Tested in a Marketing Cloud Next email on 2026-11-22:
{{dateAdd "2024-02-29" 1 "Y"}}renders2025-02-28T00:00:00. The documented result is2025-02-28 00:00:00.{{dateAdd "2025-01-31" 1 "D"}}renders2025-02-01T00:00:00. The documented result is2025-02-01 00:00:00.
Show Next test script
Differs from official docs
- The reference states the result is a date-time string shaped
yyyy-MM-dd HH:mm:ss, with a space between date and time, and shows2025-02-28 00:00:00for its leap-year example. In Marketing Cloud Next (tested 2026-11-22): The date math was right, but the separator is aT:{{dateAdd "2024-02-29" 1 "Y"}}rendered2025-02-28T00:00:00and{{dateAdd "2025-01-31" 1 "D"}}rendered2025-02-01T00:00:00. Code that compares or splits the result on the space breaks. Details
Marketing Cloud Next
Differs from the documentation
The date math is right, but the output format is not: the documentation shows a space between date and time (2025-02-28 00:00:00), while MCN puts a T there (2025-02-28T00:00:00). Tested 2026-11-22 by rendering in a Marketing Cloud Next email.
See also
- AMPscript
DateAdd— the AMPscript equivalent - Official reference