This content has been marked as final. Show 3 replies
Use the DateTime class in .net, and pass it to/from Oracle using the DateTime Oracle data type in your parameters. It'll handle the conversion on it's own.
there are few places where date is passed as string '01 Jan 2013' and datatype is varchar.
i do not want to changed this
will stored procedure be able to handel this, in situations stated above.
if not what measures i should take.
Edited by: 944768 on Apr 25, 2013 7:56 AM
Edited by: 944768 on Apr 25, 2013 7:57 AM
Edited by: 944768 on Apr 25, 2013 8:01 AM
Edited by: 944768 on Apr 25, 2013 8:02 AM
If you're doing it with strings, you need to explicitly set the date format so that what you're passing in is consistent. For example, this would take a .net DateTime that was in any format, and turn it into a string:
That will work the same way no matter what you set the server date/time format to. You'll need to do the same thing when bringing dates back out of Oracle, and set it explicitly. The InvariantCulture stuff tells it to ignore different cultural settings, to ensure it works reliably.
DateTime aDate = DateTime.Now; string aDateString = aDate.ToString("yyyy/MM/dd", CultureInfo.InvariantCulture);
That said, by far the superior way of doing this is to use the Date and Time formats in Oracle, and to use DateTime objects in .net. Those are designed exactly for this scenario, and store the date in a neutral format so all you have to do is display it in the local format.