This function formats a date/time string in the specified format pattern and locale.



Ordinal Type Required Description
1 String True The date string to format
2 String True The output date format pattern (see table below for valid values)
3 String False The output time format pattern (see table below for valid values)
4 String False The ISO locale code for the output

These are the valid format patterns, given a date of 2017-09-15T06:07:08.1230000-06:00:

Element Format Pattern Output
Long l Friday, September 15, 2017
Short s 9/15/2017
Month, Year Y September, 2017
Year YY 17
Year YYYY 2017
Month M September 15
Month MM 09
Month MMM Sep
Month MMMM September
Day dd 15
Day dddd Fri
Day ddddd Friday
Hour hh 06
Minutes mm 07
Seconds ss 08
Milliseconds (time only) MM 123
Timezone offset zz -06
Timezone offset zzz -06:00

NOTE: Format patterns are not case-sensitive, but they must be used in the correct pattern argument (for example, both mm and MM are date and time formats).

NOTE: This function returns lowercase month and day names for non-US culture codes by default.



var @dateString, @timeString, @dateISO, @dateRFC, @dateLong, @dateShort, @frFRDate, @monthYear, @yearShort, @yearFull, @monthNameDay, @monthNumber, @monthShortName, @monthFullName, @dayNumber, @dayShortName, @dayFullName, @hour, @minute, @seconds, @milliseconds, @AMPM, @offsetHours, @offsetHoursMinutes

set @dateString = "2017-09-15T06:07:08.1230000-06:00"
set @timeString = "06:08:07.123 AM"

set @dateISO  = FormatDate(@dateString,"iso")
set @dateRFC  = FormatDate(@dateString,"rfc")
set @dateLong  = FormatDate(@dateString,"l")
set @dateShort  = FormatDate(@dateString,"s")
set @frFRDate = properCase(FormatDate(@dateString,"l","","fr-FR"))

set @monthYear = FormatDate(@dateString,"Y")
set @yearShort = FormatDate(@dateString,"YY")
set @yearFull = FormatDate(@dateString,"YYYY")
set @monthNameDay = FormatDate(@dateString,"M")
set @monthNumber = FormatDate(@dateString,"MM")
set @monthShortName = FormatDate(@dateString,"MMM")
set @monthFullName = FormatDate(@dateString,"MMMM")
set @dayNumber = FormatDate(@dateString,"dd")
set @dayShortName = FormatDate(@dateString,"dddd")
set @dayFullName = FormatDate(@dateString,"ddddd")

set @hour = FormatDate(@timeString,"","hh")
set @minute = FormatDate(@timeString,"","mm")
set @seconds = FormatDate(@timeString,"","ss")
set @milliseconds = FormatDate(@timeString,"","MMM")
set @AMPM = FormatDate(@timeString,"","tt")
set @offsetHours = FormatDate(@dateString,"zz")
set @offsetHoursMinutes = FormatDate(@dateString,"zzz")

dateString: %%=v(@dateString)=%%
<br>dateISO: %%=v(@dateISO)=%%
<br>dateRFC: %%=v(@dateRFC)=%%
<br>dateLong: %%=v(@dateLong)=%%
<br>dateShort: %%=v(@dateShort)=%%
<br>frFRDate: %%=v(@frFRDate)=%%
<br><br>monthYear: %%=v(@monthYear)=%%
<br>yearShort: %%=v(@yearShort)=%%
<br>yearFull: %%=v(@yearFull)=%%
<br>monthNameDay: %%=v(@monthNameDay)=%%
<br>monthNumber: %%=v(@monthNumber)=%%
<br>monthShortName: %%=v(@monthShortName)=%%
<br>monthFullName: %%=v(@monthFullName)=%%
<br>dayNumber: %%=v(@dayNumber)=%%
<br>dayShortName: %%=v(@dayShortName)=%%
<br>dayFullName: %%=v(@dayFullName)=%%
<br><br>timeString: %%=v(@timeString)=%%
<br>hour: %%=v(@hour)=%%
<br>minute: %%=v(@minute)=%%
<br>seconds: %%=v(@seconds)=%%
<br>milliseconds: %%=v(@milliseconds)=%%
<br>AMPM: %%=v(@AMPM)=%%
<br>offsetHours: %%=v(@offsetHours)=%%
<br>offsetHoursMinutes: %%=v(@offsetHoursMinutes)=%%


dateString: 2017-09-15T06:07:08.1230000-06:00
dateISO: 2017-09-15T06:07:08.1230000-06:00
dateRFC: Fri, 15 Sep 2017 06:07:08 GMT
dateLong: Friday, September 15, 2017
dateShort: 9/15/2017
frFRDate: Vendredi 15 Septembre 2017

monthYear: September, 2017
yearShort: 17
yearFull: 2017
monthNameDay: September 15
monthNumber: 09
monthShortName: Sep
monthFullName: September
dayNumber: 15
dayShortName: Fri
dayFullName: Friday

timeString: 06:07:08.123 AM
hour: 06
minute: 07
seconds: 08
milliseconds: 123
offsetHours: -06
offsetHoursMinutes: -06:00