Defining a custom date‑and‑time format
You can define a custom date‑and‑time format using special symbols to construct a format pattern. Use custom date formatting only for reports that are viewed in a single locale. Custom formats always display dates in the format you set. This format can be inappropriate for other locales. For example, if you use the format MM‑dd‑yy, the date January 10, 2006, always appears as 01‑10‑06, regardless of the locale in which the report is viewed. For locales in which dates customarily appear in day‑month‑year format, the date 01‑10‑06 is interpreted as October 1, 2006.
Table 2‑3 lists the specials symbols used to define custom date‑and‑time formats.
Table 2‑3 Symbols for defining custom date‑and‑time formats
Symbol | Description | Example |
yy | Short year | 08 |
yyyy | Long year | 2008 |
MM | Month as a number | 07 |
MMM | Short month name | Jul |
MMMM | Full month name | July |
d | Day in month | 10 |
W | Week in month | 2 |
w | Week in year | 28 |
DD | Day in year | 192 |
E | Short day of week | Thu |
EEEE | Long day of week | Thursday |
H | Hour in day (0 ‑ 23) | 0 |
k | Hour in day (1 ‑ 24) | 24 |
K | Hour in AM/PM (0 ‑ 11) | 0 |
h | Hour in AM/PM (1 ‑ 12) | 12 |
mm | Minutes | 30 |
ss | Seconds | 55 |
a | AM or PM | 8:00:00AM |
Table 2‑4 shows examples of custom formats and their effects on a date that is stored as April 15, 2006 12:15:30 PM.
Table 2‑4 Examples of custom date‑and‑time formats
Format pattern | Result of formatting |
MM‑dd‑yy | 04‑15‑06 |
E, M/d/yyyy | Fri, 4/15/2006 |
MMM d | Apr 15 |
MMMM | April |
yyyy | 2006 |
W | 3 (the week in the month) |
w | 15 (the week in the year) |
DD | 105 (the day in the year) |
h:mm:ss | 12:15:30 |