Character
|
Meaning
|
Example Data
|
Example String
|
Example Result
|
D
|
Day of the month, with no leading zero.
|
1/1/2020
|
M-D-YY
|
1-1-20
|
DD
|
Day of the month, with leading zero.
|
1/1/2020
|
MM-DD-YY
|
01-01-20
|
DDD
|
Day of the week, abbreviated.
|
7/4/1996
|
DDD
|
Thu
|
DDDD
|
Full day of the week.
|
7/4/1996
|
DDDD
|
Thursday
|
M
|
Number of the month, with no leading zero.
|
1/1/2020
|
M-D-YY
|
1-1-20
|
MM
|
Number of the month, with leading zero.
|
1/1/2020
|
MM-DD-YY
|
01-01-20
|
MMM
|
Name of the month, abbreviated.
|
1/1/2020
|
MMM
|
Jan
|
MMMM
|
Full name of the month.
|
1/1/2020
|
MMMM
|
January
|
Y
|
Number of the day in the year (1-366).
|
1/1/2020
|
Y
|
1
|
YY
|
Last 2 digits of the year.
|
1/1/2020
|
M-D-YY
|
1-1-20
|
YYY or YYYY
|
All 4 digits of the year.
|
1/1/2020
|
M-D-YYYY
|
1-1-2020
|
h
|
Hour from 1-12, with no leading zero.
|
8:05 pm
|
h:mm
|
8:05
|
hh
|
Hour from 1-12, with leading zero.
|
8:05 pm
|
hh:mm
|
08:05
|
H
|
Hour from 1-24, with no leading zero.
|
8:05 pm
|
H:mm
|
20:05
|
HH
|
Hour from 1-24, with leading zero.
|
3:00 am
|
HH:mm
|
03:00
|
m
|
Minute, with no leading zero.
|
3:09 am
|
h:m
|
3:9
|
mm
|
Minute, with leading zero.
|
3:09 am
|
h:mm
|
3:09
|
s
|
Seconds, with no leading zero.
|
3:09 am
|
h:m:s
|
3:9:0
|
ss
|
Seconds, with leading zero.
|
5:07:02 am
|
hh:mm:ss
|
05:07:02
|
AM/PM
|
Adds letters AM or PM after the date/time data to indicate morning or afternoon/evening hours.
|
5:07:02 am
|
h:mm AM/PM
|
5:07 AM
|
Literals such as / - : and space characters
|
Any character in the format string that is not a special character will appear in the output data exactly as typed.
|
1/1/2020
8:05 am
|
m-d-yy
h:m:s
|
1-1-20
8:5:0
|