I tried this but I get the ORA-00947 error:not enough values. The format of the existing date field in the ora db is--> October 17,2001 1:15:33 PM The format I get from following timestamp code is -->2001-10-17 13:13:19.485 I cant believe that oracle would be that picky since it is a date field? Thanks to all that replied, I will keep trying to get this to work(seems like such a simple task) Graham -----Original Message----- From: David Sean Taylor [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 17, 2001 12:08 PM To: [EMAIL PROTECTED] Subject: RE: java.util.Date() into a java.sql.Date
with oracle all dates are actually timestamps, so you can use jdbc timestamps: java.util.Date date = new java.util.Date(); // get timestamp now java.sql.Timestamp timeStamp = new java.sql.Timestamp(date.getTime()); ps.setTimestamp( 2, timeStamp ); > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, October 17, 2001 9:15 AM > To: [EMAIL PROTECTED] > Subject: java.util.Date() into a java.sql.Date > Importance: Low > > > Hi, I have a prepared statement that requires a date for Oracle db. > Basically it is a field that records time and date that record was > created(timestamp). I use this to get time and date : > java.util.Date utilDate = new java.util.Date(); > //Now I need to convert this utilDate into a sqlDate to use > in a prepared > statement. I need this: October 17, 2001 11:00:00PM which > util gives me but > I cant get it to sql type > ps.setDate(2,sqlDate); > > > How can I convert or better yet grab the current date/time as > a sql.Date to > begin with. > THANKS!! > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]