?
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
Medium Priority
?
1,740 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

764 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