XSD datatype
xs: gYear and friends
Gregorian fragments — a year, a month, a day, or a pair of them — for dates that are genuinely partial. gMonth is '--08', with both hyphens.
The g-types cover recurring or partial dates: gYear (2026), gYearMonth (2026-08), gMonth (--08), gDay (---18) and gMonthDay (--08-18). The leading hyphens are part of the lexical form and are what people forget.
gMonth and gMonthDay are for recurring dates — a birthday, a fiscal month — where the year is deliberately absent rather than unknown.
- Lexical space
- YYYY for gYear; YYYY-MM for gYearMonth; --MM, ---DD, --MM-DD for the rest.
- Derives from
- Primitive type
- Category
- Date and time types
- Facets
- minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration, whiteSpace
The schema used
This is the exact schema the literals above are validated against. Paste it into the validator with one of them to see the result yourself.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="v" type="xs:gYear"/>
</xs:schema>Related
- xs:dateA calendar date, zero-padded, with an optional timezone that almost nobody expects it to have — which means it is not always a fixed 24-hour period.
- xs:dateTimeA date and time in ISO 8601 form, requiring the T separator and zero-padding. Timezone is optional, which causes more trouble than it saves.
Get started
Bring order to the XML your team can't afford to ignore.
Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.