Solved

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

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

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.   …
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 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