I need to convert a string datetime "2006-03-16T17:12:36.328" (which is sourced from an XML document), into a string that is acceptable to be used in a SQL insert statement.
[tt]dim d as system.datetime = ctype("2006-03-16T17:12:36.328", system.datetime)
' or perhaps
dim d as system.datetime
system.DateTime.TryParse("2006-03-16T17:12:36.328", d)
Use the XmlConvert class to convert it from your XmlDocument to a .net DateTime variable, which is then understood natively by SqlParameter objects you would use in your query.
This format is called ISO-8601, and is the W3C-specified format for storing dates in XML. Any other format you see in XML that people send you is merely a string that somewhat resembles a date. ;-)
Chip H.
____________________________________________________________________ If you want to get the best response to a question, please read FAQ222-2244 first
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.