Back to Devexpress

Date and Time Format Switch

officefileapi-15287-word-processing-document-api-fields-format-switches-date-and-time-format-switch.md

latest1.7 KB
Original Source

Date and Time Format Switch

  • Sep 19, 2023
  • 2 minutes to read

@ [“] switch-argument [“]

Word Processing Document API supports the following date and time format codes:

SpecifierDescriptionSample Result
dDisplays the day as a number, 1 through 31 .5
ddDisplays the day as a number, 01 through 31 .05
dddDisplays the 3-letter day of the week abbreviation according to the current culture.Fri
ddddDisplays the full day of the week according to the current culture.Friday
MDisplays the month as a number, 1 through 12.6
MMDisplays the month as a number, 01 through 12.06
MMMDisplays the 3-letter month abbreviation according to the current culture.Nov
MMMMDisplays the full month name according to the current culture.November
yyDisplays the 2-digit year.20
yyyyDisplays 4-digit year.2020
hDisplays the hour on 12-hour clock, 1 through 124
HDisplays the hour on 12-hour clock, 01 through 1204
hhDisplays the hour on 24-hour clock, 0 to 23.4 or 20
HHDisplays the hour on 24-hour clock, 00 to 23.04 or 20
mDisplays minutes, 0 to 59.8
mmDisplays minutes, 00 to 59.08
am/pmDisplays time using am/pm notation, lowercase.04:20 AM
AM/PMDisplays time using am/pm notation, uppercase.04:20 am
ssDisplays seconds, 01 to 59.05

Examples:

  1. Field code {DATE @ “‘Today is ‘MMM. d, yyyy”} results in Today is Dec. 29, 2011
  2. Field code {DATE @ “‘Current time is ‘HH:mm:ss”} results in Current time is 17:13:15