Formats a string, date, or number in a specified format.
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
Format(input,
outputFormat,
dataFormat,
cultureCode)
The Format() function has four parameters:
-
input(datetime, number, or string): Required. The string to apply formatting rules to. -
outputFormat(string): Required. A format string to apply toinput. -
dataFormat(string): The data format of the string. Possible values areDateandNumber.note: For best results, always specify a value for
dataFormat. If you don’t specify a value fordataFormat, the function tries to determine the type of the input data. -
cultureCode(string): A culture code to apply to the string.
Format Codes for Numeric Values
Use these codes to format strings as numeric values.
| Code | Output Format |
|---|---|
C |
Currency |
D |
Decimal |
E |
Scientific notation |
F |
Fixed-point |
G |
General |
N |
Number |
P |
Percent |
You can also format strings as dates. See Pre-Defined Date Formats and Custom Date Formats.
Usage
You can use this function to format strings in several different ways. These examples show some of the ways that you can use this function.
Pre-Defined Date Formats
The Format() function can format a date string into one of several predefined formats. To format a date using one of these formats, specify the format string for outputFormat and specify Date for dataFormat.
This table lists the formats that are available in both Marketing Cloud Engagement and Marketing Cloud Next. Because the output value can vary based on the locale, this table includes example values for the en_US, fr_FR, and ja_JP locales.
| Description | Format String | Examples |
|---|---|---|
| Short date | d |
<ul><li>(en_US) 8/5/2026</li><li>(fr_FR) 05/08/2026</li><li>(ja_JP) 2026/08/05</li></ul> |
| Long date | D |
<ul><li>(en_US) Wednesday, August 5, 2026</li><li>(fr_FR) mercredi 5 août 2026</li><li>(ja_JP) 2026 年 8 月 5 日</li></ul> |
| Long date and short time | f |
<ul><li>(en_US) Wednesday, August 5, 2026 1:45 PM</li><li>(fr_FR) mercredi 5 août 2026 13:45</li><li>(ja_JP) 2026 年 8 月 5 日 13:45</li></ul> |
| Long date and long time | F |
<ul><li>(en_US) Wednesday, August 5, 2026 1:45:30 PM</li><li>(fr_FR) mercredi 5 août 2026 13:45:30</li><li>(ja_JP) 2026 年 8 月 5 日 13:45:30</li></ul> |
| General date with short time | g |
<ul><li>(en_US) 8/5/2026 1:45 PM</li><li>(fr_FR) 05/08/2026 13:45</li><li>(ja_JP) 2026/08/05 13:45</li></ul> |
| General date with long time | G |
<ul><li>(en_US) 8/5/2026 1:45:30 PM</li><li>(fr_FR) 05/08/2026 13:45:30</li><li>(ja_JP) 2026/08/05 13:45:30</li></ul> |
| Month and day | m or M |
<ul><li>(en_US) August 5</li><li>(fr_FR) 5 août</li><li>(ja_JP) 8 月 5 日</li></ul> |
| Round-trip date and time | o or O |
<ul><li>(en_US) 2026-08-05T13:45:30.1230000</li><li>(fr_FR) 2026-08-05T13:45:30.1230000</li><li>(ja_JP) 2026-08-05T13:45:30.1230000</li></ul> |
| RFC1123 date and time | r or R |
<ul><li>(en_US) Wed, 05 Aug 2026 13:45:30 GMT</li><li>(fr_FR) Wed, 05 Aug 2026 13:45:30 GMT</li><li>(ja_JP) Wed, 05 Aug 2026 13:45:30 GMT</li></ul> |
| Sortable date and time | s |
<ul><li>(en_US) 2026-08-05T13:45:30</li><li>(fr_FR) 2026-08-05T13:45:30</li><li>(ja_JP) 2026-08-05T13:45:30</li></ul> |
| Short time | t |
<ul><li>(en_US) 1:45 PM</li><li>(fr_FR) 13:45</li><li>(ja_JP) 13:45</li></ul> |
| Long time | T |
<ul><li>(en_US) 1:45:30 PM</li><li>(fr_FR) 13:45:30</li><li>(ja_JP) 13:45:30</li></ul> |
| Universal sortable date and time | u |
<ul><li>(en_US) 2026-08-05 13:45:30Z</li><li>(fr_FR) 2026-08-05 13:45:30Z</li><li>(ja_JP) 2026-08-05 13:45:30Z</li></ul> |
| Universal full date and time | U |
<ul><li>(en_US) Wednesday, August 5, 2026 1:45:30 PM</li><li>(fr_FR) mercredi 5 août 2026 13:45:30</li><li>(ja_JP) 2026 年 8 月 5 日 13:45:30</li></ul> |
| Month and year | y or Y |
<ul><li>(en_US) August 2026</li><li>(fr_FR) août 2026</li><li>(ja_JP) 2026 年 8 月</li></ul> |
Custom Date Formats
You can format a date string using a custom format by passing a string that specifies the format. The strings that you use vary depending on whether you use Marketing Cloud Engagement or Marketing Cloud Next.
Day and Date Format Strings
| Description | Example | String (MC Engagement) | String (MC Next) |
|---|---|---|---|
| Full day name | Monday | dddd |
EEEE |
| Abbreviated day name | Mon | ddd |
EEE |
| Date (zero-padded) | 05 | dd |
dd |
| Date (non-zero-padded) | 5 | d |
d |
| Day number in week | 1 | (not available) | u |
Month Format Strings
| Description | Example | String (MC Engagement) | String (MC Next) |
|---|---|---|---|
| Full month name | August | MMMM |
MMMMM |
| Abbreviated month name | Aug | MMM |
MMM |
| Month number (zero-padded) | 08 | MM |
MM |
| Month number (non-zero-padded) | 8 | M |
M |
Year Format Strings
| Description | Example | String (MC Engagement) | String (MC Next) |
|---|---|---|---|
| Full year number | 2026 | yyyy |
yyyy |
| Last two digits of year | 26 | yy |
yy |
| Calendar era | AD | gg |
G |
Time Format Strings
| Description | Example | String (MC Engagement) | String (MC Next) |
|---|---|---|---|
| Hour (24-hour, zero-padded) | 13 | HH |
HH |
| Hour (24-hour, non-zero-padded) | 13 | H |
H |
| Hour (12-hour, zero-padded) | 01 | hh |
hh |
| Hour (12-hour, non-zero-padded) | 1 | h |
h |
| Minute (zero-padded) | 05 | mm |
mm |
| Minute (non-zero-padded) | 5 | m |
m |
| Second (zero-padded) | 09 | ss |
ss |
| Second (non-zero-padded) | 9 | s |
s |
| Millisecond | 423 | fff |
S |
| AM/PM marker (two letter) | PM | tt |
a |
| AM/PM marker (first letter only) | P | t |
(not available) |
| Time zone name | UTC | (not available) | z |
| Time zone offset (hours and minutes, zero-padded) | -0800 | zzz |
Z |
| Time zone offset (hours only, zero-padded) | -08 | zz |
X |
| Time zone offset (hours only, non-zero-padded) | -8 | z |
X |
This example shows how to format the date to include the full name of the day ("dddd"), the full name of the month ("MMMM"), the date without a leading zero ("d"), and the year ("yyyy"). It also shows the time in 24-hour format, including hours, minutes, seconds, and UTC offset ("HH:mm:ss (zzz)").
%%[
Var @now, @dateString
Set @now = "5 August 2026 1:41:23 PM"
Set @dateString = Format(@now, "dddd, MMMM d yyy HH:mm:ss (zzz)", "Date", "en_US")
]%%
<p>Date and time with a custom format: %%=v(@dateString)=%%</p>
The function outputs the date and time using the format that you specified.
Date and time with a custom format: Wednesday, August 5 2026 1:41:23 (-06:00)
You can use the cultureCode parameter to express day and month names in other languages. This example outputs the date using day and month names in Swahili.
%%[
Var @now, @dateString
Set @now = "5 August 2026 1:41:23 PM"
Set @dateString = Format(@now, "ddddd, d MMMM yyyy", "date", "sw_KE")
]%%
<p>Date and time with a custom format: %%=v(@dateString)=%%</p>
The function outputs the date string with the appropriate values translated.
Date and time with a custom format: Jumatano, 5 Agosti 2026
Formatting Currency Values
%%[
Var @cost, @finalCostInDollars
Set @cost = "31.4159"
Set @finalCostInDollars = Format(@cost,"C2")
]%%
<p>The total price is %%=v(@finalCostInDollars)=%%.</p>
The function outputs the string expressed as a dollar amount rounded to two decimal places.
The total price is $31.42.
You can use the cultureCode parameter to express currency values for a different country. This example outputs the currency value in Indian Rupees.
%%[
Var @cost, @finalCostInRupees
Set @cost = "3141.5926535"
Set @finalCostInRupees = Format(@cost, "C0", "", "bn_IN")
]%%
<p>চূড়ান্ত মূল্য %%=v(@finalCostInRupees)=%%</p>
The function outputs the currency value expressed in Indian rupees, rounded to the nearest whole number.
চূড়ান্ত মূল্য ₹ 3,142
See Also
- NumberFormatInfoClass Class on the Microsoft Developer Network
- DateTimeFormatInfo Class on the Microsoft Developer Network