FormatDate()
Formats a string as a date value.
| Marketing Cloud Engagement | ✅ Yes |
| Marketing Cloud Next | ✅ Yes, with some differences |
This function became available in Marketing Cloud Next during the Summer ’26 release (API version 67.0).
In Marketing Cloud Engagement, this function uses standard .NET date and time formatting libraries. In Marketing Cloud Next, this function uses the Java SimpleDateFormat class, which uses different formatting strings.
In Marketing Cloud Next, if you don’t specify a value for the dateFormat parameter, the function returns a string formatted with the G standard format. This format uses a combination of a short date value and a long time value. For example, in the en_US locale, this function outputs a timestamp that’s similar to this example: 5/15/2026 1:23:45 PM.
The FormatDate() function has these parameters:
dateString(string): Required. The date string that you want to format.dateFormat(string): A string that represents the format to apply to the date.timeFormat(string): A string that represents the format to apply to the time.localeCode(string): The locale code to use when formatting the date.
In Marketing Cloud Engagement, you can specify a date in these formats.
| Description | Format | Example |
|---|---|---|
| ISO timestamp | yyyy-MM-dd'T'HH:mm:ss.fffzzz | 2026-08-05T13:45:30.123-0700 |
| Japanese notation | yyyy '年' M '月' d '日' | 2026 年 8 月 5 日 |
| Korean notation | yyyy'년' M'월' d'일' | 2026년 8월 5일 |
| Sortable date | yyyy-MM-dd | 2026-08-05 |
| Sortable date and time | yyyy-MM-dd HH:mm:ss | 2026-08-05 13:45:30 |
| US Customary date (non-zero-padded) | M/d/yyyy | 8/5/2026 |
| US Customary date (zero-padded) | MM/dd/yyyy | 08/05/2026 |
| US Customary date and time (12-hour time, non-zero-padded) | M/d/yyyy h:mm:ss tt | 8/5/2026 1:45:30 |
| US Customary date and time (24-hour time, zero-padded) | MM/dd/yyyy HH:mm:ss | 08/05/2026 13:45:30 |
| US Customary date and time with time zone | MM/dd/yyyy HH:mm:ss fff | 08/05/2026 13:45:30 -0700 |
In Marketing Cloud Next, you can specify a date in these formats.
| Description | Format | Example |
|---|---|---|
| ISO timestamp | yyyy-MM-dd'T'HH:mm:ss.SSSZ | 2026-08-05T13:45:30.123-0700 |
| Sortable date | yyyy-MM-dd | 2026-08-05 |
| Sortable date and time | yyyy-MM-dd HH:mm:ss | 2026-08-05 13:45:30 |
| US Customary date (zero-padded) | MM/dd/yyyy | 08/05/2026 |
| US Customary date and time (24-hour time, zero-padded) | MM/dd/yyyy HH:mm:ss | 08/05/2026 13:45:30 |
| US Customary date and time with time zone | MM/dd/yyyy HH:mm:ss ZZZ | 08/05/2026 13:45:30 -0700 |
To use this function, supply it with a date to format. If you don’t pass any other parameters, the function formats the date string according to the locale settings for your Marketing Cloud Engagement business unit or your Marketing Cloud Next org. This example formats a date string to use the default locale setting for an account based in the United States.
The function outputs the date and time.
The FormatDate() function can format a date string into one of several predefined formats. 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, the full name of the month, the date without a leading zero, and the year. It also shows the time in a 24-hour format, including hours, minutes, and seconds. This example works with Marketing Cloud Engagement.
In Marketing Cloud Next, use this example instead.
The function outputs the date and time using the format that you specified.
You can format a date string into a format that aligns with the common notation for a locale by passing S or L for the dateFormat parameter, and the locale code for the localeCode parameter.
The code outputs the short- and long-form date strings for the specified locales.