Date conversion problem *URGENT*

V

Vishal

Hey,

I have differnt kind of dates. They can be in this format:

Thur, 23 Sept 2004 14:24:15 GMT
Thur, 23 Sept 2004 14:24:15 PST
Thur, 23 Sept 2004 14:24:15 CST

and so on....

Now when I try to convert this string to a date then I get
the error:

The string was not recognized as a valid DateTime. There
is a unknown word starting at index 0.

If I remove the words GMT, PST, CST then it works. BUT is
there any possiblity to get this converted without remove
these words?

Thanks
 
O

Ollie

are you using the System.Convert.ToDateTime ? if so try using DateTime.Parse
method (static on DateTime class)

HTH

Ollie Riches
 
V

Vishal

I tried both and got the same result.

Dim dtDate As DateTime = Convert.ToDateTime(strPostDate)

or

Dim dtDate As DateTime = DateTime.Parse(strPostDate)

BTW: I recognized that when removing GMT doesnt help. I
get: The string was not recognized as a valid DateTime.
There is a unknown word starting at index 0. The first
problem does exist too.
 
V

Vishal

Update If I remove the "t" from "Sept" and "GMT" then it
works.... There must a better way?
 
O

Ollie

you can use a IFormatProvider interface, have a look at the CultureInfo
class, you could also specific the format of the DateTime.Parse i believe

HTH

Ollie Riches
 

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