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
Symbol | Description |
---|---|
d, dd | The day in the month, represented as a number between 1 and 31. |
D, DD, DDD | The day in the year, represented as a number between 1 and 366. |
F | The day of the week in the month, represented as a number between 1 and 5. |
w, ww | The week in the year, represented as a number between 1 and 52. |
W | The week in the month, represented as a number between 1 and 4. |
M, MM | The month in the year, represented as a number between 1 and 12. |
yy, yyyy | The year. |
K, KK | The hour in the day, represented in 12-hour format as a number between 1 and 12. |
k, kk | The hour in the day, represented in 24-hour format as a number between 0 and 23. |
m, mm | The minute in the hour, represented as a number between 0 and 59. |
s, ss | The second in the minute, represented as a number between 0 and 59. |
S, SS, SSS | The 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
Token | Description |
---|---|
E, EEEE | The day name in the week. |
G | The era, represented as AD or BC. |
a | The AM/PM marker, represented as AM or PM. |
MMM, MMMM | The month in the year. |
z, zzzz | The 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"
.