473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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
4 4402
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

70
by: Roy Yao | last post by:
Does it mean "(sizeof(int))* (p)" or "sizeof( (int)(*p) )" ? According to my analysis, operator sizeof, (type) and * have the same precedence, and they combine from right to left. Then this...
2
by: terry | last post by:
Hi, When I store cookie value "12:05:33" and read it again, I find the value become "12%3A05%3A33", how to read or convert it correctly? Thanks!
3
by: Albert Wagner | last post by:
I have just had a problem that I cannot find any reference to in any docs. Admittedly, I am a JavaScript newbie, but this sure seems like a bug or an "undocumented feature" in Opera 7.11. I have...
3
by: Brad Quinn | last post by:
Is there a way to add an assembly to the .NET tab of the "Add Reference" dialog?
4
by: Peter Hemmingsen | last post by:
Hi, I have a dotnet object (implemented in mc++ and used in c#) which have a property called "Info". The Info property is also a dotnet object (implemented in mc++). In the constructor of the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.