Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi guys..

I am trying to insert the System date in oracle and i am facing the problem with the format.The format is mm/dd/yyyy but oracle takes the date in format dd-mmm-yy format.

Can anybody help me to convert this date into the required format?
Posted
Comments
Sergey Alexandrovich Kryukov 25-Apr-11 23:34pm    
If you say it's solved, are you going to formally accept the answers (green button)?
Thank you.
--SA

You can use the ToString method of DateTime class. Pass the necessary format, in your case dateTime.Now.ToString(“dd/mm/yyyy”);

Take a look at this article[^] for further reading.
 
Share this answer
 
v3
Comments
Sergey Alexandrovich Kryukov 25-Apr-11 23:30pm    
Correct (actually, not exactly right format; better fix it, use "/" and "mm"). Will you fix it?
See my answer for more detail.
--SA
Tarakeshwar Reddy 25-Apr-11 23:31pm    
Thanks SA upated it. 5 for your answer and your update
This is quite easy.

This is related to Date and Time formatting:
http://msdn.microsoft.com/en-us/library/az4se3k1.aspx[^],
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx[^].

Here is how you can use custom time formatting to obtain the date to your spec:
System.DateTime time = System.DataTime.Now; //just for example

//...

string timeOracle = time.ToString("dd/mm/yyyy");


You can also format string to a specified culture:
string timeOracle =
   time.ToString(new CultureInfo("en-gb")); //it looks like what Oracle uses, according the the question


—SA
 
Share this answer
 
v4

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900