By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,656 Members | 1,009 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,656 IT Pros & Developers. It's quick & easy.

How to parse this date: "2003-10-29T17:44+00:00"

P: n/a
Hello,

I have a date string in the following format: "2003-10-29T17:44+00:00"

When I put it to DateTime.Parse() method it throws an exception, how do I
parse this date format?

Thanks,

/m
Nov 15 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
In DateTime.Parse you need to specify the FormatInfo. Create a custom
FormatInfo that defines the format you are using and when trying to use
DateTime.Parse() specify that format info

Thanks,
Jagan Mohan
"Muscha" <mu****@no.spam.net> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl...
Hello,

I have a date string in the following format: "2003-10-29T17:44+00:00"

When I put it to DateTime.Parse() method it throws an exception, how do I
parse this date format?

Thanks,

/m

Nov 15 '05 #2

P: n/a
That format looks a lot like a xml date time format. Maybe you could try the
XmlConvert.ToDateTime() method in the System.Xml namespace.

Muscha wrote:
Hello,

I have a date string in the following format: "2003-10-29T17:44+00:00"

When I put it to DateTime.Parse() method it throws an exception, how
do I parse this date format?

Thanks,

/m

Nov 15 '05 #3

P: n/a
Sam
An alternative would be to do a string replace on the T
character, as replacing this with a space will allow it
to parse normally.

e.g. this works

string s = "2002-10-31T12:30+01:00";
s = s.Replace("T", " ");
t = DateTime.Parse(s);

Sam
-----Original Message-----
In DateTime.Parse you need to specify the FormatInfo. Create a customFormatInfo that defines the format you are using and when trying to useDateTime.Parse() specify that format info

Thanks,
Jagan Mohan
"Muscha" <mu****@no.spam.net> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl...
Hello,

I have a date string in the following format: "2003-10- 29T17:44+00:00"
When I put it to DateTime.Parse() method it throws an exception, how do I parse this date format?

Thanks,

/m

.

Nov 15 '05 #4

P: n/a
Muscha,
Have you looked at DateTime.ParseExact with a custom format?

Something like (minimally tested in VB.NET):

string format = "yyyy-MM-ddTHH:mmzzz";
string s = "2003-10-29T17:44+00:00";

DateTime d = DateTime.ParseExact(s, format, null);

Which is very close to the "s" & "u" standard formats, except for the time
zone on the end...

Hope this helps
Jay

"Muscha" <mu****@no.spam.net> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl...
Hello,

I have a date string in the following format: "2003-10-29T17:44+00:00"

When I put it to DateTime.Parse() method it throws an exception, how do I
parse this date format?

Thanks,

/m

Nov 15 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.