Discussion Locked

Load Date & Time to an Oracle Date field

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Can anyone tell me how to load a date and time into an Oracle Date field.

I am trying to load a date/time stamp into an Oracle table to record when a transaction was processed.

I am using PreparedStatement to load parameters for the SQL.

I have tried setDate, setTime & set Timestamp.
This will give the date but no time component.

Any help would be greatly appreciated.
Thanks

5 replies

by nise_k

Hi,

There are 2 ways you could do this :
1. in the insert query - set the date field value as - TO_DATE(TO_CHAR(SYSDATE,'DD-MON-YYYY HH:MI:SS AM'))
This will insert the time component as well.

2. if you want to pass the time from your program itself then use the java functions to create a new Date().
Get the dd, mm, yyyy and the h,m ,s. Concatenate these and pass it to the database.

Nise

by roland11

Maybe your Oracle table field type is defined as Date - it should be DateTime.

Greetings
Roland

This discussion is closed to new replies.