Click here to Skip to main content
Rate this: bad
good
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 1:27am
Rate this: bad
good
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.
  Permalink  
Rate this: bad
good
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
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 505
1 OriginalGriff 248
2 ChintanShukla 185
3 Richard Deeming 175
4 Bhavik_Patel 170
0 Sergey Alexandrovich Kryukov 8,688
1 OriginalGriff 7,237
2 CPallini 2,598
3 Richard MacCutchan 2,080
4 Abhinav S 1,888


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 26 Feb 2013
Copyright © CodeProject, 1999-2014
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