By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,745 Members | 1,873 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,745 IT Pros & Developers. It's quick & easy.

Invalid date in C#

P: 132
Hi there.

I am trying to pass a date from a TextBox in my (c#) web page when invoking an insert button.

The date in question is of the type DD/MM/YYYY and has a value of "14/09/2007" but when the process runs, I am receiving an error of the type:

ORA-01843: not a valid month

I am assuming this is because of American style date format (mm/dd/yyyy) but I'm not sure how to convert this within my code (or other) so could somebody advise please?

Thank you.

Mark :o)
Mar 3 '09 #1
Share this Question
Share on Google+
3 Replies

Expert 5K+
P: 7,872
Use DateTime.ParseExact() and then give the custom format you want to it
Mar 3 '09 #2

P: 132
Thank you for that. I used the to_date method within the sql body in the end up and that worked okay. It wasn't working originally as I had the mask/format in lower case, i.e.

to_date('txtString.Text', 'dd/mm/yyyy') but then it worked with:


Thank you.

M :o)
Mar 3 '09 #3

Expert 100+
P: 229
Actually, mm stands for minutes, and MM are months, so for a full date with time you would use something like this:

Expand|Select|Wrap|Line Numbers
  1. dd/MM/yyyy HH:mm:ss
Capital Y and D are not defined (but it seems that somehow it works anyway).

Custom Date and Time Format Strings
Mar 4 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.