The following code performs powerful Date type validation in XSD. It validates date fields with
timestamp (optional) in
yyyyMMdd hh:MM:ss.ffffff format.
If your XML file contains the element ValueDate, the corresponding XSD will be this:
<xs:element name="ValueDate" type="dateType"/>
<xs:simpleType name= "timestampType">
<xs:restriction base = "xs:string">
<xs:pattern value='[1-9][0-9][0-9][0-9](([0][1|3|5|7|8])([0][1-9]|[1-2][0-9]|[3][0-1])|([0][4|6|9])
([0][1-9]|[1-2][0-9]|[3][0])|([0][2])([0][1-9]|[1-2][0-9])|([1][0|2])([0][1-9]|[1-2][0-9]|[3][0-1])|([1]
[1])([0][1-9]|[1-2][0-9]|[3][0]))([ ]([2][1-4]|[0][0-9]|[1][0-9])[:]([0-5][0-9]|[6][0])[:]([0-5][0-9]|[6]
[0])[.][0-9]{6})*'/>
</xs:restriction>
</xs:simpleType>
</code></pre>