First things first: In DB, if the column type is DATE, it doesn't store the date values in a particular 'format' (dd-MMM-yyyy or whatever). What it stores is some kind of a number or expression which helps it to uniquely indicate a date value. So, your statement
I want to insert into the table as dd-mm-yyyy format..
is not valid. If the column type is DATE (which I assume as you were inserting a value using 'to_date') then it will hold date-value and not string (formatted).
What I can realize from your post is that while getting the value back, you may want to display (or parse) it as dd-MMM-yyyy. However, for this you have to SELECT the value using 'to_char'. The value in DB is of type DATE and can be retrieved in ANY format. So, something like
Joined: Dec 28, 2005
Dear Aditya , Thanks for your reply. What my problem is I've the code for inserting a date column in Oracle table
for egs : String d = "10-11-2006" insert into aa values (to_char('dd-mm-yyyy',d);
This is working perfectly in Oracle 8i.
Now my client want to host the site.. and he wants to conver the oracle to MySQL for hosting. So in a particular point there is no to_char function in MySQL. So i could't inser the date into the MySQL table..
My Doubt : How to insert a date column into MySQL table ?
Originally posted by Aravind Prasad: I want to insert into the table as dd-mm-yyyy format..
Well regarding your dateformat requirement you have to follow the SimpleDateFormat class its helps you to apply the format whatever you want. What you need to do to create an object of simpleDateFormat class by defining a format into the constructor in string.
Your code would be like this.. what Aditya refer you above.. try this..