Click here to Skip to main content
12,821,041 members (43,123 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# Oracle
I want to save today's date from C# to oracle for the following format:

02/26/2013 05:58:50 PM

Could you please send me the code for C#
Posted 26-Feb-13 2:27am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Just pass it as a DateTime using Oracle Parameter.AddWithValue[^] - you should not convert datatypes unnecessarily, so if the target accepts DateTime values (and all DB's do) then it is pointless converting it and introducing the possibility of errors due to incompatible formats.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Hello friend,

in C# you need to cast your date using this format same as you required

DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt")

and while using oracle you need to cast it back to your Date, you can use this format in oracle

SELECT TO_CHAR(sysdate,'MM/dd/yyyy hh:mi:ss AM') from dual

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170308.1 | Last Updated 26 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100