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,530 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

806 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