NexJ Logo

Date and time patterns

Date and time patterns are string values that you create to define a date format. They are used in some date and time functions to change the display format of the date that is returned by the function.

In field control formulas, date values are timestamps that represent a specific date and time. Because date values are stored in forms and contact profiles as timestamps, they are not formatted in a way that can be easily read by most people. The DateFormat() and DateTimeFormat() functions allow you to specify how you want the date to be displayed when it is returned by the function. To do this, you provide the function with a date and time pattern argument, which formats the date according the pattern.

Number patterns

Use number patterns to specify how numeric values are displayed in a formatted date. You can use the following symbols to represent numbers in a date and time pattern:

Number pattern symbols for use in date and time patterns

SymbolDescription
d, ddThe day in the month, represented as a number between 1 and 31.
D, DD, DDDThe day in the year, represented as a number between 1 and 366.
FThe day of the week in the month, represented as a number between 1 and 5.
w, wwThe week in the year, represented as a number between 1 and 52.
WThe week in the month, represented as a number between 1 and 4.
M, MMThe month in the year, represented as a number between 1 and 12.
yy, yyyyThe year.
K, KKThe hour in the day, represented in 12-hour format as a number between 1 and 12.
k, kkThe hour in the day, represented in 24-hour format as a number between 0 and 23.
m, mmThe minute in the hour, represented as a number between 0 and 59.
s, ssThe second in the minute, represented as a number between 0 and 59.
S, SS, SSSThe millisecond in the second, represented as a number between 0 and 999.

The number of consecutive letters of each symbol determines the minimum number of digits that are displayed for that symbol's number. For example, if you format the date January 31, 2000 using the pattern "DD", the function returns the date as the formatted string value "31", because January 31 is the 31st day of the year. If you format the same date using the pattern "DDD", the function returns the date as the formatted string value "031".

Text patterns

Use text patterns to specify how text values are displayed in a formatted date. You can use the following symbols to represent text in a date and time pattern:

Text pattern symbols for use in date and time patterns

TokenDescription
E, EEEEThe day name in the week.
GThe era, represented as AD or BC.
aThe AM/PM marker, represented as AM or PM.
MMM, MMMMThe month in the year.
z, zzzzThe time zone.

The number of consecutive letters of each symbol determines whether the short or long form is displayed for that symbol's text. If the number of consecutive letters is four, the long form is used. For all symbols except M, if the number of consecutive letters is less than three, the short form is used. For the symbol M, if the number of consecutive letters is three, the short form is used. For example, if you format the date January 31, 2000 using the pattern "MMM", the function returns the date as the formatted string value "Jan". If you format the same date using the pattern "MMMM", the function returns the date as the formatted string value "January".

DateFormat()
DateTimeFormat()