Solved

System.FormatException: The ERROR -> string was not recognized as a valid DateTime. There is an unknown word starting at index 2.

Posted on 2014-02-11
2
1,568 Views
Last Modified: 2014-02-28
Hi im trying to convert a string into date time like so
Dim dtTime As DateTime = Convert.ToDateTime(div.selectSingleNode(kickofftime).InnerText)

Open in new window


But im getting the error  System.FormatException: The string was not recognized as a valid DateTime. There is an unknown word starting at index 2.

Below is the list of times im trying to change - i believe it could be the ones that say tomorrow in the text?!?!?!?

13:30
14:00
14:45
14:45
14:45
16:30
Tomorrow 14:45
Tomorrow 14:45
0
Comment
Question by:runnerjp2005
2 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 39850966
You cannot convert "Tomorrow" in a Convert.ToDateTame. You need a date.

I do not know where you get your information, but "Tomorrow" should be replaced by something like

Cstr(Date.Today.AddDays(1)).ToString
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39850975
The word "Tomorrow" isn't valid as a DateTime component in .NET. .NET does not have PHP's flexibility when it comes to date parsing--at least not built into the Framework. To get this kind of functionality, you will need to employ a 3rd-party library (or write your own). I recall seeing such a library some time back, but I'm having trouble locating it. I'll dig around a bit more.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question