Hi to all,
I have a PostgreSql database table which contains field of type date .I want to insert the date in the format of “dd-MMM-YYYY”. I am using the preparedStatement to insert the date field as well as other fields to the table.Please help me.
you can insert the date as
where, person is a reference to a class Person.
The date will be inserted in yyyy-mm-dd format.
you can use the sql date formatting options for outputting it the way u like
Thanks umar ali for your reply and help. I have tried that way but there is no date formating functions are avail for the class java.sql.Date which are compactable with the pst.setDate() method (where pst is the reference to the type java.sql.PreparedStatement).The pstmt.setDate(1,date) method only accept java.sql.Date type arguments.So I didn’t got the expected result
The date formatting functions are not in java.sql. package but your database vendors provide the formatting functions for outputting the date. For ex.
SELECT BIRTHDATE(TO_DATE("DD-MM-YYYY")) FROM USER;
Check ur database vendor manual for details
thanks for your reply .I will try