Date Conversion probs

V

Vishal

Hello,

I am trying to convert a date from a string like this:

Dim dtDate As DateTime = Convert.ToDateTime("Sun, 07 Nov
2004 14:05:04 +0200")
Response.Write(dtDate.ToString("dd MMM yyyy"))

However I am getting the error:

"String was not recognized as a valid DateTime. "

Its because of the "+200". What is the best way to convert
such a date?

Thanks
 
K

Ken Cox [Microsoft MVP]

Are you asking how to preserve the time zone information in the datetime,
how to adjust for the times zone, or how to lop off the last five characters
of the string to make it acceptable?
 
V

Vishal

Hello Ken,

I simply want to convert the "Sun, 07 Nov
2004 14:05:04 +0200" to a valid date. Nothing more and
nothing less.

Vishal
 
K

Ken Cox [Microsoft MVP]

Just trim the last five or six characters before the conversion.
 
V

Vishal

I was hoping for a conversion solution, but I think there
isnt any. Thanks anyway for your help Ken.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top