Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WriteXML and DateTime

Status
Not open for further replies.

majkinetor

Programmer
Feb 21, 2006
88
RS
Hi there.

My DataTable is loaded with some Excell Sheet wich have DateTime column. When I open excell file I see what user have enter in format day.month.year but when I export this table via WriteXML this date is changed to some other format + it added time component wich was originaly absent.

I need to keep original input. How can I change this behavior.

I tried to create another table and set it columns to string type and then import rows of original table (the one loaded from Excell) but the data was changed during SELECT * statement when I was loading xls to DataSet so nothing was fixed, but the format was little different at the end.

Can I somehow specify witch format for DateTime WriteXML should use ? MAybe something about IFormatProvider ?

Thx

 
The W3C XML standard is to use ISO-8601 date formatting (yyyy-mm-ddThh:mm:ss.nnnn±Zhh:mm), so it's doing it correctly.

If the system that your XML is feeding into doesn't understand this (and if it doesn't, it's broken), you can change the column type in your dataset to a string/char, and just have a column that contains a string that just happens to resemble a date (for your locale!)

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
>>>you can change the column type in your dataset to a string

Not here!
column type can not be changed once table is created. U might think now why I don't change DataTable definition but I don't have any, I use only one SELECT * to grab data and together with schema from xls file. So, dataTable is modeled by XLS shema witch I can't change.

Another way is to create new datatable itereate and insert rows manulay after I create them again just to change datetime values into format I want.

The problem is much deaper, and according to Microsoft it will be deal with in new versions of dotNet. Some reference:


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top