Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How do I insert date/time into a ORACLE date field?????? - new to ORACLE
Glynn Smith wrote:
> I am new to ORACLE and
> trying to store date/time information in a date field. I need help in
> doing the following:
>
> insert into fi_test(create_date) values ( x );
>
> where x is what I need help in formating. I have tried the following for
> x:
>
> '1/20/1997 12:34:23'
> '12-23-1996 1:435:34'
> '1-JAN-97 12:45:43'
You are close. If you do not specify a format mask on a date field it
wants the data in ORACLE default which is usually 'DD-MON-YY' with no
time. You can do what you want with if you make x the following:
to_date('1/20/1997 12:34:23', 'M/D/YYYY HH24:MI:SS')
Note that the format mask is specified in the to_date. Also note that the abbreviation for minutes in the format mask is MI and not MM which is a mistake many people make (if you accidentally use MM you will get the month instead of minutes).
Chris Halioris
Tactics, Inc.
Received on Tue Jan 21 1997 - 00:00:00 CST