Solved

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

Posted on 2003-11-24
5
732 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
Comment Utility
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
Comment Utility
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
Comment Utility
ALWAYS use dates in the UNambigous format yyyy-mm-dd which is the ODBC format.
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 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

12 Experts available now in Live!

Get 1:1 Help Now