w:date (Date Picker Content Control)
Declares a structured document tag as a date picker content control, storing a date value and specifying its display format.
Parent elements
Child elements
Description
w:date classifies an SDT as a date picker content control. It stores the canonical date value in the w:fullDate attribute (ISO 8601) and defines child elements that control how the date is formatted for display and which calendar system is used.
It is defined in ECMA-376 Part 1 §17.5.2.7.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
w:fullDate |
xsd:dateTime |
ISO 8601 date-time string | The currently selected date value. |
Child Elements
| Element | Description |
|---|---|
w:dateFormat |
Display format string (e.g. MMMM d, yyyy). |
w:lid |
Language/locale for date formatting. |
w:storeMappedDataAs |
Whether to store as dateTime, date, or text in XML mapping. |
w:calendar |
Calendar system: gregorian, hijri, hebrew, etc. |
Examples
<w:sdt>
<w:sdtPr>
<w:alias w:val="Contract Date"/>
<w:date w:fullDate="2024-06-15T00:00:00Z">
<w:dateFormat w:val="MMMM d, yyyy"/>
<w:lid w:val="en-US"/>
<w:storeMappedDataAs w:val="dateTime"/>
<w:calendar w:val="gregorian"/>
</w:date>
</w:sdtPr>
<w:sdtContent>
<w:r><w:t>June 15, 2024</w:t></w:r>
</w:sdtContent>
</w:sdt>
using DocumentFormat.OpenXml.Wordprocessing;
var sdtDate = new SdtDate(
new DateFormat { Val = "MMMM d, yyyy" },
new LanguageId { Val = "en-US" },
new SdtDateMappingType { Val = SdtDateMappingValues.DateTime },
new Calendar { Val = CalendarValues.Gregorian }
)
{ FullDate = new System.DateTime(2024, 6, 15) };
Notes
- The text displayed in
w:sdtContentis a pre-formatted representation; the canonical value is alwaysw:fullDate. w:dateFormatuses locale-dependent format tokens (M,d,y,H, etc.) similar to .NET date format strings.