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.

DescriptionFormatExample
ISO timestampyyyy-MM-dd'T'HH:mm:ss.fffzzz2026-08-05T13:45:30.123-0700
Japanese notationyyyy '年' M '月' d '日'2026 年 8 月 5 日
Korean notationyyyy'년' M'월' d'일'2026년 8월 5일
Sortable dateyyyy-MM-dd2026-08-05
Sortable date and timeyyyy-MM-dd HH:mm:ss2026-08-05 13:45:30
US Customary date (non-zero-padded)M/d/yyyy8/5/2026
US Customary date (zero-padded)MM/dd/yyyy08/05/2026
US Customary date and time (12-hour time, non-zero-padded)M/d/yyyy h:mm:ss tt8/5/2026 1:45:30
US Customary date and time (24-hour time, zero-padded)MM/dd/yyyy HH:mm:ss08/05/2026 13:45:30
US Customary date and time with time zoneMM/dd/yyyy HH:mm:ss fff08/05/2026 13:45:30 -0700

In Marketing Cloud Next, you can specify a date in these formats.

DescriptionFormatExample
ISO timestampyyyy-MM-dd'T'HH:mm:ss.SSSZ2026-08-05T13:45:30.123-0700
Sortable dateyyyy-MM-dd2026-08-05
Sortable date and timeyyyy-MM-dd HH:mm:ss2026-08-05 13:45:30
US Customary date (zero-padded)MM/dd/yyyy08/05/2026
US Customary date and time (24-hour time, zero-padded)MM/dd/yyyy HH:mm:ss08/05/2026 13:45:30
US Customary date and time with time zoneMM/dd/yyyy HH:mm:ss ZZZ08/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.

DescriptionFormat StringExamples
Short dated
  • (en_US) 8/5/2026
  • (fr_FR) 05/08/2026
  • (ja_JP) 2026/08/05
Long dateD
  • (en_US) Wednesday, August 5, 2026
  • (fr_FR) mercredi 5 août 2026
  • (ja_JP) 2026 年 8 月 5 日
Long date and short timef
  • (en_US) Wednesday, August 5, 2026 1:45 PM
  • (fr_FR) mercredi 5 août 2026 13:45
  • (ja_JP) 2026 年 8 月 5 日 13:45
Long date and long timeF
  • (en_US) Wednesday, August 5, 2026 1:45:30 PM
  • (fr_FR) mercredi 5 août 2026 13:45:30
  • (ja_JP) 2026 年 8 月 5 日 13:45:30
General date with short timeg
  • (en_US) 8/5/2026 1:45 PM
  • (fr_FR) 05/08/2026 13:45
  • (ja_JP) 2026/08/05 13:45
General date with long timeG
  • (en_US) 8/5/2026 1:45:30 PM
  • (fr_FR) 05/08/2026 13:45:30
  • (ja_JP) 2026/08/05 13:45:30
Month and daym or M
  • (en_US) August 5
  • (fr_FR) 5 août
  • (ja_JP) 8 月 5 日
Round-trip date and timeo or O
  • (en_US) 2026-08-05T13:45:30.1230000
  • (fr_FR) 2026-08-05T13:45:30.1230000
  • (ja_JP) 2026-08-05T13:45:30.1230000
RFC1123 date and timer or R
  • (en_US) Wed, 05 Aug 2026 13:45:30 GMT
  • (fr_FR) Wed, 05 Aug 2026 13:45:30 GMT
  • (ja_JP) Wed, 05 Aug 2026 13:45:30 GMT
Sortable date and times
  • (en_US) 2026-08-05T13:45:30
  • (fr_FR) 2026-08-05T13:45:30
  • (ja_JP) 2026-08-05T13:45:30
Short timet
  • (en_US) 1:45 PM
  • (fr_FR) 13:45
  • (ja_JP) 13:45
Long timeT
  • (en_US) 1:45:30 PM
  • (fr_FR) 13:45:30
  • (ja_JP) 13:45:30
Universal sortable date and timeu
  • (en_US) 2026-08-05 13:45:30Z
  • (fr_FR) 2026-08-05 13:45:30Z
  • (ja_JP) 2026-08-05 13:45:30Z
Universal full date and timeU
  • (en_US) Wednesday, August 5, 2026 1:45:30 PM
  • (fr_FR) mercredi 5 août 2026 13:45:30
  • (ja_JP) 2026 年 8 月 5 日 13:45:30
Month and yeary or Y
  • (en_US) August 2026
  • (fr_FR) août 2026
  • (ja_JP) 2026 年 8 月

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.

DescriptionExampleString (MC Engagement)String (MC Next)
Full day nameMondayddddEEEE
Abbreviated day nameMondddEEE
Date (zero-padded)05dddd
Date (non-zero-padded)5dd
Day number in week1(not available)u
DescriptionExampleString (MC Engagement)String (MC Next)
Full month nameAugustMMMMMMMMM
Abbreviated month nameAugMMMMMM
Month number (zero-padded)08MMMM
Month number (non-zero-padded)8MM
DescriptionExampleString (MC Engagement)String (MC Next)
Full year number2026yyyyyyyy
Last two digits of year26yyyy
Calendar eraADggG
DescriptionExampleString (MC Engagement)String (MC Next)
Hour (24-hour, zero-padded)13HHHH
Hour (24-hour, non-zero-padded)13HH
Hour (12-hour, zero-padded)01hhhh
Hour (12-hour, non-zero-padded)1hh
Minute (zero-padded)05mmmm
Minute (non-zero-padded)5mm
Second (zero-padded)09ssss
Second (non-zero-padded)9ss
Millisecond423fffS
AM/PM marker (two letter)PMtta
AM/PM marker (first letter only)Pt(not available)
Time zone nameUTC(not available)z
Time zone offset (hours and minutes, zero-padded)-0800zzzZ
Time zone offset (hours only, zero-padded)-08zzX
Time zone offset (hours only, non-zero-padded)-8zX

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.