?
Solved

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

Posted on 2003-11-24
5
Medium Priority
?
803 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 160 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

CHALLENGE LAB: Troubleshooting Connectivity Issues

Goal: Fix the connectivity issue in the lab's AWS environment so that you can SSH into the provided EC2 instance.  

Question has a verified solution.

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

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

765 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