V
vooose
Suppose you have a DataTable which is part of a DataSet that has a
column of type DateTime.
When you call
ds.GetXml()
the date comes out looking something like this:
2005-01-17T23:01:34.9526250+11:00
An article I came across
(http://www.c-sharpcorner.com/Code/2003/July/FormatDateTimeInXml.asp)
says the format should be more like 'CCYY-MM-DDThh:mm:ss' but it clearly
isnt on my machine - I am getting to 1/10millionth of a second and the
timezone! That article suggests a way to customize the DateTime output
by calling ds.GetXml(), reading it back in, then writing it out again. I
don't really like that way.
I compared the output to all the DateTime.ToString() variants and it
doesnt seem to match any! Looking at the DataSet schema didnt shed any
light either:
<xs:element name="Item" type="xs:dateTime" minOccurs="0" />
Does anyone know of a way to output the DateTime in the format of your
choice? (without writing/reading back in)
I was thinking perhaps you can set the DateTime format as a property
somewhere on the DataSet, but can't find anything! There is much to this
class.
Regards
column of type DateTime.
When you call
ds.GetXml()
the date comes out looking something like this:
2005-01-17T23:01:34.9526250+11:00
An article I came across
(http://www.c-sharpcorner.com/Code/2003/July/FormatDateTimeInXml.asp)
says the format should be more like 'CCYY-MM-DDThh:mm:ss' but it clearly
isnt on my machine - I am getting to 1/10millionth of a second and the
timezone! That article suggests a way to customize the DateTime output
by calling ds.GetXml(), reading it back in, then writing it out again. I
don't really like that way.
I compared the output to all the DateTime.ToString() variants and it
doesnt seem to match any! Looking at the DataSet schema didnt shed any
light either:
<xs:element name="Item" type="xs:dateTime" minOccurs="0" />
Does anyone know of a way to output the DateTime in the format of your
choice? (without writing/reading back in)
I was thinking perhaps you can set the DateTime format as a property
somewhere on the DataSet, but can't find anything! There is much to this
class.
Regards