Format a date
Details about format used for the date functions
The following table defines the token substrings you can use in a date-time format pattern for the functions DATEPARSE(str, format) and DATEFORMAT(date, format).
You can define the format
field by combining the tokens shown below.
Usual format token
Examples below given for 2014-08-06T13:07:04.054
considered as a local time in America/New_York
To display | Use this token | Example |
---|---|---|
year, unpadded | y |
|
two-digit year | yy |
|
four- to six- digit year, pads to 4 | yyyy |
|
month as an unpadded number | M |
|
month as a padded number | MM |
|
month as an abbreviated localized string | MMM |
|
month as an unabbreviated localized string | MMMM |
|
month as a single localized letter | MMMMM |
|
day of the month, no padding | d |
|
day of the month, padded to 2 | dd |
|
hour in 12-hour time, no padding | h |
|
hour in 12-hour time, padded to 2 | hh |
|
hour in 24-hour time, no padding | H |
|
hour in 24-hour time, padded to 2 | HH |
|
minute, no padding | m |
|
minute, padded to 2 | mm |
|
second, no padding | s |
|
second, padded to 2 padding | ss |
|
fractional seconds, functionally identical to SSS | u |
|
fractional seconds, between 0 and 99, padded to 2 | uu |
|
fractional seconds, between 0 and 9 | uuu |
|
millisecond, no padding | S |
|
millisecond, padded to 3 | SSS |
|
Advanced format token
Examples below given for 2014-08-06T13:07:04.054
considered as a local time in America/New_York
To display | Use this token | Example |
---|---|---|
ordinal (day of year), unpadded | o |
|
ordinal (day of year), padded to 3 | ooo |
|
quarter, no padding | q |
|
quarter, padded to 2 |
| |
ISO week year, unpadded | kk |
|
ISO week year, padded to 4 | kkkk |
|
ISO week number, unpadded | W |
|
ISO week number, padded to 2 | WW |
|
Local week year, unpadded | ii |
|
Local week year, padded to 4 | iiii |
|
Local week number, unpadded | n |
|
Local week number, padded to 2 | nn |
|
day of the week, as number from 1-7 (Monday is 1, Sunday is 7) | E |
|
day of the week, as an abbreviate localized string | EEE |
|
day of the week, as an unabbreviated localized string | EEEE |
|
day of the week, as a single localized letter | EEEEE |
|
localized numeric date | D |
|
localized date with abbreviated month | DD |
|
localized date with full month | DDD |
|
localized date with full month and weekday | DDDD |
|
localized time | t |
|
localized time with seconds | tt |
|
localized time with seconds and abbreviated offset | ttt |
|
localized time with seconds and full offset | tttt |
|
localized 24-hour time | T |
|
localized 24-hour time with seconds | TT |
|
localized 24-hour time with seconds and abbreviated offset | TTT |
|
localized 24-hour time with seconds and full offset | TTTT |
|
short localized date and time | f |
|
less short localized date and time | ff |
|
verbose localized date and time | fff |
|
extra verbose localized date and time | ffff |
|
short localized date and time with seconds | F |
|
less short localized date and time with seconds | FF |
|
verbose localized date and time with seconds | FFF |
|
extra verbose localized date and time with seconds | FFFF |
|
narrow offset | Z |
|
short offset | ZZ |
|
techie offset | ZZZ |
|
abbreviated named offset | ZZZZ |
|
unabbreviated named offset | ZZZZZ |
|
IANA zone | z |
|
meridiem | a |
|
unix timestamp in seconds | X |
|
unix timestamp in milliseconds | x |
|
Last updated