Format()
Formats a string, date, or number in a specified format.
| 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).
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.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.
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.
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.
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 |
|
| Long date | D |
|
| Long date and short time | f |
|
| Long date and long time | F |
|
| General date with short time | g |
|
| General date with long time | G |
|
| Month and day | m or M |
|
| Round-trip date and time | o or O |
|
| RFC1123 date and time | r or R |
|
| Sortable date and time | s |
|
| Short time | t |
|
| Long time | T |
|
| Universal sortable date and time | u |
|
| Universal full date and time | U |
|
| Month and year | y or Y |
|
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.
| 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 |
| 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 |
| 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 |
| 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)”).
The function outputs the date and time using the format that you specified.
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.
The function outputs the date string with the appropriate values translated.
The function outputs the string expressed as a dollar amount rounded to two decimal places.
You can use the cultureCode parameter to express currency values for a different country. This example outputs the currency value in Indian Rupees.
The function outputs the currency value expressed in Indian rupees, rounded to the nearest whole number.
- NumberFormatInfoClass Class on the Microsoft Developer Network
- DateTimeFormatInfo Class on the Microsoft Developer Network