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,435 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 74

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now