Date and time display formats

The following table lists characters that can appear in a format string for date and time formats.

Format String Character Description

:

Time separator. (In some locales, other characters may be used to represent the time separator.)

This character separates hours, minutes and seconds when time values are formatted. The actual character used as the time separator in formatted output is determined by your system settings.

/

Date separator. (In some locales, other characters may be used to represent the date separator.)

The date separator separates the day, month, and year when date values are formatted. The actual character used as the date separator in formatted output is determined by your system settings.

C

Displays the date as ddddd and displays the time as ttttt, in that order. Displays only date information if there is no fractional part to the date serial number. Displays only time information if there is no integer portion.

Example: 10/10/98 05:12:12

d

Displays the day as a number without a leading zero (1-31).

dd

Displays the day as a number with a leading zero (01-31).

ddd

Displays the day as an abbreviation (Sun-Sat).

dddd

Displays the day as a full name (Sunday-Saturday).

ddddd

Displays the date as a complete date (including day, month, and year), formatted according to the long date setting recognized by your system. For Microsoft Windows, the default long date is m/d/yy.

dddddd

Displays a date serial number as a complete date (including day, month, and year), formatted according to the long date setting recognized by your system. For Microsoft Windows, the default long date format is mmmm dd, yyyy.

w

Displays the day of the week as a number. (1 for Sunday through 7 for Saturday).

ww

Displays the weeks of the year as a number (1 - 54)

m

Displays the month as a number without a leading zero (1 - 12). If m immediately follows h or hh, the minute rather than the month displays.

mm

Displays the month as a number with a leading zero (01 - 12). If m immediately follows h or hh, the minute rather than the month displays.

mmm

Displays the month as an abbreviation (Jan - Dec).

mmmm

Displays the month as a full month name (January - December)

q

Displays the quarter of the year as a number (1 - 4).

y

Displays the day of the year as a number ( 1 - 366).

yy

Displays the year as a two-digit number (00 - 99).

yyy

Displays the year as a four-digit number (0100 - 9999).

h

Displays the hour as a number without leading zeros (0 - 23).

hh

Displays the hour as a number with leading zeros (01 - 23).

n

Displays the minute as a number without leading zeros (0 - 59).

nn

Displays the minute as a number with leading zeros (00 - 59).

s

Displays the second as a number without leading zeros (0 - 59).

ss

Displays the second as a number with leading zeros (00 - 59).

t t t t t

Displays a time as a complete time (including hour, minute, and second), formatted using the system time separator. A leading zero displays if the time is before 10:00 AM or 10:00 PM. For Microsoft Windows, the default time format is hh:mm:ss.

AM/PM

Uses the 12-hour clock. Displays an uppercase AM with any hour before noon; displays an uppercase PM with any hour between noon and 11:59 P.M.

am/pm

Uses the 12-hour clock. Displays a lowercase AM with any hour before noon; displays a lowercase PM with any hour between noon and 11:59 P.M.

A/P

Uses the 12-hour clock. Displays an uppercase A with any hour before noon; displays an uppercase P with any hour between noon and 11:59 P.M.

a/p

Uses the 12-hour clock. Displays a lowercase a with any hour before noon; displays a lowercase p with any hour between noon and 11:59 P.M.

AMPM

Uses the 12-hour clock. Displays the AM string literal with any hour before noon; displays the PM string literal with any hour between noon and 11:59 P.M. AMPM can be either uppercase or lowercase, but the case of the string displayed matches the string as defined by your system settings. For Microsoft Windows, the default format is AM/PM.