Hi, I'm validating a Xml against a schema but I get error validating ISO 8601 datetime value. The fragment of the schema is <xs:attribute name="fecha" use="required"> <xs:simpleType> <xs:restriction base="xs:dateTime"> <xs:whiteSpace value="collapse"/> </xs:restriction> </xs:simpleType> </xs:attribute> The value that contains the field "fecha" is '2008-06-30T14:52:00' It is supposed to be a valid ISO 8601 local time but the schema rejects it. Only when using '2008-06-30T14:52:00Z' the schema accepts the value. But in order to do that I should convert my datetime to UTC which I'm trying to avoid. Is it any way to fix the schema declaration to accept ISO 8601 local datetime? This problem was present when using typed xml data type in Sql Server 2005. Any hint is welcomed Thanks in advance Sammy
SQL 2005 requires a time offset. You can replace the Z with your local time offset, like -05:00 for Eastern time, like this: 2008-06-30T14:52:00-05:00 Keep in mind that SQL Server "normalizes" xs:dateTime values to Z time, so it will literally store the value above as: 2008-06-30T09:52:00Z This behavior is changed in SQL Server 2008. One alternative is to create a type derived from xs:string that restricts it's content to the desired format. -- ======== Michael Coles "Pro SQL Server 2008 XML" http://www.amazon.com/Pro-SQL-Server-2008-XML/dp/1590599837/ "SammyBar" wrote in message news:%23VOZsiv2IHA.2060@TK2MSFTNGP02.phx.gbl... > Hi, > > I'm validating a Xml against a schema but I get error validating ISO 8601 > datetime value. > > The fragment of the schema is > <xs:attribute name="fecha" use="required"> > <xs:simpleType> > <xs:restriction base="xs:dateTime"> > <xs:whiteSpace value="collapse"/> > </xs:restriction> > </xs:simpleType> > </xs:attribute> > > The value that contains the field "fecha" is '2008-06-30T14:52:00' > > It is supposed to be a valid ISO 8601 local time but the schema rejects > it. Only when using '2008-06-30T14:52:00Z' the schema accepts the value. > But in order to do that I should convert my datetime to UTC which I'm > trying to avoid. > Is it any way to fix the schema declaration to accept ISO 8601 local > datetime? > > This problem was present when using typed xml data type in Sql Server > 2005. > > Any hint is welcomed > Thanks in advance > Sammy >