The case sensitivity of the tostring method of the date object affects the output result. As follows. Incorrect usage :? Convert. todatetime ("2005/12/22 22:22:22"). tostring ("yyyy/mm/dd hh: mm: SS ")
"Yyyy/12/DD 22: 12: SS"
? Convert. todatetime ("2005/12/22 22:22:22"). tostring ("yyyy/mm/dd hh: mm: SS ")
"2005/22/22 10:22:22" correct usage: Convert. todatetime ("22:22:22"). tostring ("yyyy/mm/dd hh: mm: SS ")
"22:22:22" common numerical formats are shown in the following table:
Format String data result
"{0: c}" 12345.6789 $12,345.68
"{0: c}"-12345.6789 ($12,345.68)
"{0: d}" 12345 12345
"{0: D8}" 12345 00012345
"{0: e}" 12345.6789 1234568e + 004
"{0: E10 }" 12345.6789 1.2345678900e + 004
"{0: F }" 12345.6789 12345.68
"{0: F0 }" 12345.6789 12346
"{0: g}" 12345.6789 12345.6789
"{0: G7}" 123456789 1.234568e8
"{0: n}" 12345.6789 12,345.68
"{0: N4}" 123456789 123,456,789.0000
"Total: {0: c}" 12345.6789 total: $12345.68
The following table lists the commonly used date formats:
Format description output format
D. Simplified Date Format: mm/DD/YYYY
D detailed Date Format: dddd, Mmmm DD, yyyy
F full format (long date + short time) dddd, Mmmm DD, yyyy hh: mm
F
Complete Date and Time Format
(Long date + long time)
Dddd, Mmmm DD, yyyy hh: mm: SS
G General Format (short date + short time) mm/DD/YYYY hh: mm
G General Format (short date + long time) mm/DD/YYYY hh: mm: SS
M, M month/day format mmmm dd
S moderate Date and Time Format: yyyy-mm-dd hh: mm: SS
T simplified time format hh: mm
T detailed time format hh: mm: SS