I am trying insert asp.net form field values to oracle database table. I have a date field which is in "MM-DD-YYYY" format. I need to add that date to oracle table. So i am trying to convert that date format to "DD-MMM-YYYY" format. But i am getting the following error.
code:
var creation_date = DateTime.ParseExact(CreationDateTextBox.Text, "DD-MMM-YYYY",null);
Text box value is: 12-12-2013.(No time) i am getting error like "String was not recognized as a valid DateTime".
DateTime.ParseExact("12-dec-2013", "dd-MMM-yyyy",null)
– DamithInt64
counting ticks. So you cannot "convert" aDateTime
from one format to another. You can "convert" (i.e. parse) aString
to get aDateTime
. But to do that, you need to tell the parse method the format of theString
you're parsing from. In this case:"MM-dd-yyyy"
. Then, if you want to display that abstract number of ticks, you convert it back to the human readable form you like:date.ToString("dd-MMM-yyyy")
. But putting it into a DB should not require that. – Corak