Custom date and time format strings
Custom date and time format strings format dates in Date/Time fields.
Format specifier | Description |
---|---|
d | Represents the day of the month as a number from 1 through 31. A single-digit day is formatted without a leading zero. |
dd | Represents the day of the month as a number from 01 through 31. A single-digit day is formatted with a leading zero. |
ddd | Represents the abbreviated name of the day of the week |
dddd (plus any number of additional d specifiers) | Represents the full name of the day of the week |
f | Represents the most significant digit of the seconds fraction; that is, it represents the tenths of a second in a date and time value. If the f format specifier is used without other format specifiers, it is interpreted as the f standard date and time format specifier. |
ff | Represents the two most significant digits of the seconds fraction; that is, it represents the hundredths of a second in a date and time value. |
fff | Represents the three most significant digits of the seconds fraction; that is, it represents the milliseconds in a date and time value. |
F | Represents the most significant digit of the seconds fraction; that is, it represents the tenths of a second in a date and time value. Nothing is displayed if the digit is zero. If the F format specifier is used without other format specifiers, it is interpreted as the F standard date and time format specifier. |
FF | Represents the two most significant digits of the seconds fraction; that is, it represents the hundredths of a second in a date and time value. However, trailing zeros or two zero digits are not displayed. |
FFF | Represents the three most significant digits of the seconds fraction; that is, it represents the milliseconds in a date and time value. However, trailing zeros or three zero digits are not displayed. |
g, gg (plus any number of additional g specifiers) | Represents the period or era, for example, A.D. Formatting ignores this specifier if the date to be formatted does not have an associated period or era string. |
h | Represents the hour as a number from 1 through 12, that is, the hour as represented by a 12-hour clock that counts the whole hours since midnight or noon. A particular hour after midnight is indistinguishable from the same hour after noon. The hour is not rounded, and a single-digit hour is formatted without a leading zero. For example, given a time of 5:43, this custom format specifier displays "5". |
hh, hh (plus any number of additional h specifiers) | Represents the hour as a number from 01 through 12, that is, the hour as represented by a 12-hour clock that counts the whole hours since midnight or noon. A particular hour after midnight is indistinguishable from the same hour after noon. The hour is not rounded, and a single-digit hour is formatted with a leading zero. For example, given a time of 5:43, this format specifier displays "05". |
H | Represents the hour as a number from 0 through 23, that is, the hour as represented by a zero-based 24-hour clock that counts the hours since midnight. A single-digit hour is formatted without a leading zero. |
HH, HH (plus any number of additional H specifiers) | Represents the hour as a number from 00 through 23, that is, the hour as represented by a zero-based 24-hour clock that counts the hours since midnight. A single-digit hour is formatted with a leading zero. |
m | Represents the minute as a number from 0 through 59. The minute represents whole minutes that have passed since the last hour. A single-digit minute is formatted without a leading zero. |
mm, mm (plus any number of additional m specifiers) | Represents the minute as a number from 00 through 59. The minute represents whole minutes that have passed since the last hour. A single-digit minute is formatted with a leading zero. |
M | Represents the month as a number from 1 through 12. A single-digit month is formatted without a leading zero. |
MM | Represents the month as a number from 01 through 12. A single-digit month is formatted with a leading zero. |
MMM | Represents the abbreviated name of the month |
MMMM | Represents the full name of the month |
s | Represents the seconds as a number from 0 through 59. The result represents whole seconds that have passed since the last minute. A single-digit second is formatted without a leading zero. |
ss, ss (plus any number of additional s specifiers) | Represents the seconds as a number from 00 through 59. The result represents whole seconds that have passed since the last minute. A single-digit second is formatted with a leading zero. |
t | Represents the first character of the AM/PM designator. The AM designator is used if the hour in the time being formatted is less than 12. Otherwise, the PM designator is used. |
tt, tt (plus any number of additional t specifiers) | Represents the AM/PM designator. The AM designator is used if the hour in the time being formatted is less than 12. Otherwise, the PM designator is used. |
y | Represents the year as a one or two-digit number. If the year has more than two digits, only the two low-order digits appear in the result. If the first digit of a two-digit year begins with a zero (for example, 2008), the number is formatted without a leading zero. |
yy | Represents the year as a two-digit number. If the year has more than two digits, only the two low-order digits appear in the result. If the two-digit year has fewer than two significant digits, the number is padded with leading zeros to achieve two digits. |
yyy | Represents the year with a minimum of three digits. If the year has more than three significant digits, they are included in the result string. If the year has fewer than three digits, the number is padded with leading zeros to achieve three digits. |
yyyy | Represents the year as a four-digit number. If the year has more than four digits, only the four low-order digits appear in the result. If the year has fewer than four digits, the number is padded with leading zeros to achieve four digits. |
yyyyy (plus any number of additional y specifiers) | Represents the year as a five-digit number. If the year has more than five digits, only the five low-order digits appear in the result. If the year has fewer than five digits, the number is padded with leading zeroes to achieve five digits. If there are additional y specifiers, the number is padded with as many leading zeroes as necessary to achieve the number of y specifiers. |
zzz | Represents hours and minutes offset from UTC. If this is a time stamp such as 1/01/2012 1:30:23 PM -07:00, then 07:00 is represented by zzz. |
: | Represents the time separator. This separator is used to differentiate hours, minutes, and seconds. |
/ | Represents the date separator. This separator is used to differentiate years, months, and days. |
" | Represents a quoted string (quotation mark). Displays the literal value of any string between two quotation marks ("). |
' | Represents a quoted string (apostrophe). Displays the literal value of any string between two apostrophe (') characters. |
%c | Represents the result associated with a c custom format specifier, when the custom date and time format string consists solely of that custom format specifier. That is, to use the d, f, F, h, m, s, t, y, z, H, or M custom format specifier by itself, the application should specify %d, %f, %F, %h, %m, %s, %t, %y, %z, %H, or %M. |
\c | Represents the escape character, and displays the character "c" as a literal when that character is preceded by the escape character (\). |