Solved

System.InvalidCastException: Cast from string "11/18/2003" to type 'Date' is not valid.

Posted on 2003-11-24
5
780 Views
Last Modified: 2011-10-03
Why can't I format this: CDate("11/18/2003") in asp.net
Do I have a culture set up somewhere different then un-us?
0
Comment
Question by:andw928
  • 2
5 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9814124
What are you trying to store this into?  If it something like this:

stringvalue = CDate("11/18/2003"), where stringvalue is a string variable, then you will get the error.
0
 
LVL 3

Accepted Solution

by:
the-edge earned 40 total points
ID: 9814417
use

        Dim x As Date

        x = System.DateTime.Parse("11/18/2003", New System.Globalization.CultureInfo("en-US", True))


the edge
0
 
LVL 5

Expert Comment

by:dc197
ID: 9814630
ALWAYS use dates in the UNambigous format yyyy-mm-dd which is the ODBC format.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 10277170
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: the-edge {http:#9814417}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheLearnedOne
EE Cleanup Volunteer
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

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 …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

756 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