Solved

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

Posted on 2003-11-24
5
744 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why, and when, to use Windows Workflow 1 31
Syntax Error 2 43
Interview questions for support of a legacy ASP.NET site 4 37
C# Single Form 8 26
IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

914 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

23 Experts available now in Live!

Get 1:1 Help Now