AMPscript Format (Next)
Format a number or a date with AMPscript Format in Marketing Cloud Next. Syntax, examples, and behaviour proven in a Marketing Cloud Next email, including the patterns whose output differs from Engagement.
Syntax
Format(value, formatString[, dataFormat, cultureCode]) → string
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
value |
string | number | date | Yes | Number, numeric string, date value or parseable date string |
formatString |
string | Yes | Standard .NET pattern; custom numeric patterns come back unformatted |
dataFormat |
string | No | Date in any capitalisation, Number or the empty string; another word makes the render fail |
cultureCode |
string | No | Locale for separators, symbols and month and day names |
Example
%%=Format(1234.555, "C2")=%%
Renders $1,234.56.
For a localised number, keep the third slot empty so the fourth can be reached:
%%=Format(1234.555, "C2", "", "de-DE")=%%
Renders 1.234,56 €, with a non-breaking space (U+00A0) before the euro sign.
For a date, put Date in the third slot:
%%[ SET @orderDate = "2026-03-04 13:52:07" ]%%
%%=Format(@orderDate, "D", "Date")=%%
Renders Wednesday, March 4, 2026.
Return value
string — the formatted value.
The result is open text. A custom numeric pattern returns the input unchanged rather than raising anything.
Behaviour
Number is a working data format. Format(1234.555, "C2", "Number") renders $1,234.56. An unknown word such as Banana in that slot makes the preview fail with HTTP 500.
Two arguments are the minimum. An email with Format(@value) cannot be saved: the content API answers HTTP 400 with “The AMPscript syntax isn’t valid”.
Standard number patterns. On 1234.555: N2 gives 1,234.56, C2 gives $1,234.56, P gives 123,455.500% (three decimals) and E gives 1.234555E03 (no plus sign, two exponent digits). The numeric string "1234.555" formats the same as the number, and "1234.5" with N2 gives 1,234.50.
A negative currency gets a minus sign. Format(-1234.555, "C2") gives -$1,234.56, not a bracketed form.
Custom numeric patterns are ignored. Format(1234.555, "#,##0.00") gives 1234.555, the input as it was.
Dates
All rows below use the input 2026-03-04 13:52:07:
| Pattern | Data format | Culture | Result |
|---|---|---|---|
yyyy-MM-dd HH:mm:ss |
Date |
2026-03-04 13:52:07 |
|
yyyy-MM-dd HH:mm:ss |
(omitted) | 2026-03-04 13:52:07 |
|
d |
Date |
3/4/2026 |
|
D |
Date |
Wednesday, March 4, 2026 |
|
D |
date |
Wednesday, March 4, 2026 |
|
dddd |
Date |
Wednesday |
|
dddd |
Date |
de-DE |
Mittwoch |
D |
Date |
fr-FR |
mercredi, mars 4, 2026 |
The data format is optional for a custom date pattern and accepts any capitalisation. The culture translates day and month names, but the French long date keeps the US order of the parts.
In the same Next email, FormatDate with the pattern yyyy-MM-dd HH:mm:ss gave the same 2026-03-04 13:52:07, minutes included.
Show Next test script
<!-- Marketing Cloud Next test script for Format. 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=[1,234.50] got=[%%=Format("1234.5","N2")=%%]</p>
<p>c2 expect=[$1,234.56] got=[%%=Format(1234.555,"C2")=%%]</p>
<p>c3 expect=[2026-03-04 13:52:07] got=[%%=Format("2026-03-04 13:52:07","yyyy-MM-dd HH:mm:ss","Date")=%%]</p>
<p>c4 expect=[mercredi, mars 4, 2026] got=[%%=Format("2026-03-04 13:52:07","D","Date","fr-FR")=%%]</p>
<p>c5 expect=[Wednesday, March 4, 2026] got=[%%[ SET @r2fdD = "2026-03-04 13:52:07" ]%%%%=Format(@r2fdD,"D","Date")=%%]</p>
<p>c6 expect=[Wednesday, March 4, 2026] got=[%%[ SET @r2fdlow = "2026-03-04 13:52:07" ]%%%%=Format(@r2fdlow,"D","date")=%%]</p>
<p>c7 expect=[1.234,56 €] got=[%%=Format(1234.555,"C2","","de-DE")=%%]</p>
<p>c8 expect=[1,234.56] got=[%%=Format(1234.555,"N2")=%%]</p>
<p>c9 expect=[123,455.500%] got=[%%=Format(1234.555,"P")=%%]</p>
<p>c10 expect=[1.234555E03] got=[%%=Format(1234.555,"E")=%%]</p>
<p>c11 expect=[1234.555] got=[%%=Format(1234.555,"#,##0.00")=%%]</p>
<p>c12 expect=[-$1,234.56] got=[%%=Format(-1234.555,"C2")=%%]</p>
<p>c13 expect=[$1,234.56] got=[%%=Format("1234.555","C2")=%%]</p>
<p>c14 expect=[3/4/2026] got=[%%[ SET @r2fdd = "2026-03-04 13:52:07" ]%%%%=Format(@r2fdd,"d","Date")=%%]</p>
<p>c15 expect=[Wednesday] got=[%%[ SET @r2fdddd = "2026-03-04 13:52:07" ]%%%%=Format(@r2fdddd,"dddd","Date")=%%]</p>
<p>c16 expect=[2026-03-04 13:52:07] got=[%%[ SET @r2fdpat = "2026-03-04 13:52:07" ]%%%%=Format(@r2fdpat,"yyyy-MM-dd HH:mm:ss","Date")=%%]</p>
<p>c17 expect=[2026-03-04 13:52:07] got=[%%[ SET @r2fdnf = "2026-03-04 13:52:07" ]%%%%=Format(@r2fdnf,"yyyy-MM-dd HH:mm:ss")=%%]</p>
<p>c18 expect=[2026-03-04 13:52:07] got=[%%[ SET @r2fdcmp = "2026-03-04 13:52:07" ]%%%%=FormatDate(@r2fdcmp,"yyyy-MM-dd HH:mm:ss")=%%]</p>
<p>c19 expect=[mercredi, mars 4, 2026] got=[%%[ SET @r2fdfr = "2026-03-04 13:52:07" ]%%%%=Format(@r2fdfr,"D","Date","fr-FR")=%%]</p>
<p>c20 expect=[Mittwoch] got=[%%[ SET @r2fdde = "2026-03-04 13:52:07" ]%%%%=Format(@r2fdde,"dddd","Date","de-DE")=%%]</p>
<p>c21 expect=[$1,234.56] got=[%%=Format(1234.555,"C2","Number")=%%]</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 fails (HTTP 500) -->
%%=Format(1234.555,"C2","Banana")=%%
<!-- email 2: expect that the save is rejected (HTTP 400) -->
%%[ SET @r2fe1 = 1234.555 ]%%%%=Format(@r2fe1)=%%
Differs from official docs
- The French long date keeps the US order. The docs show
Din French with the day number before the month. Next renderedmercredi, mars 4, 2026forfr-FR. Card - Number codes give shapes the page does not show. The docs name the codes without output examples. In Next
Pgave three decimals (123,455.500%),Egave1.234555E03, and a custom pattern such as#,##0.00returned the number unformatted. Card
Availability & differences
| Platform | Available |
|---|---|
| Marketing Cloud Engagement | Yes |
| Marketing Cloud Next | Yes, from API 67.0 |
Engagement aborts on Number as the data format; Next renders $1,234.56. Engagement applies custom patterns such as #,##0.00 (1,234.56) and brackets a negative currency (($1,234.56)); Next returns 1234.555 and -$1,234.56. P, E and the French long date also differ: Engagement gives 123,455.50%, 1.234555E+003 and mercredi 4 mars 2026, Next 123,455.500%, 1.234555E03 and mercredi, mars 4, 2026. Compared 2026-11-23 by rendering the same calls in a Marketing Cloud Next email.
See also
- FormatNumber — numbers only
- FormatCurrency — currency for a locale
- FormatDate — dates only
- Official reference