Hi Metanil - It only inserted '02-SEP-06' into the DATE column. What do I have to do to have the entire datetime inserted? Thanks, Metanil. - Jazon
Main Topics
Browse All TopicsHi Oracle friends,
How do I insert a datetime to a table, supposing I have a string like '09-02-2006 01:54:54'? I'm getting an error saying "not a valid month".
I'm pretty good with SQL Server but still a rookie with Oracle.
Thanks a bunch,
Jazon
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
>>Hi Metanil - It only inserted '02-SEP-06' into the DATE column. What do I have to do to have the entire datetime inserted? Thanks, Metanil. - Jazon<<
No, it didn't, it inserted both the date and the time. The default display format is DD-MON-YY, which is why it displays 02-SEP-06.To see the date and time you need to -
select to_char(yourdatefield,'MM-
if u cant find it in registry, then please try this..
alter session set nls_date_format='DD-MON-YY
by this in ur current session there is no need for u to covert the date format explicitly everytime u select some date field.. if u want this to be applied to the instance permanently, then u need to add the parameter to the init.ora file..
To illustrate -
SQL> create table test_date(col1 date);
Table created.
SQL> insert into test_date select to_date('09-02-2006 01:54:54','MM-DD-YYYY HH:MI:SS AM') from dual;
1 row created.
SQL> select col1 from test_date;
COL1
---------
02-SEP-06
SQL> select to_char(col1,'MM-DD-YYYY HH:MI:SS AM') from test_date;
TO_CHAR(COL1,'MM-DD-YY
----------------------
09-02-2006 01:54:54 AM
Business Accounts
Answer for Membership
by: MetanilPosted on 2006-09-02 at 00:33:15ID: 17441558
Hi piratepatrol,
user function to_date for converting the string into Oracle Date.
eg:
select to_date('09-02-2006 01:54:54','MM-DD-YYYY hh:mi:ss') from dual;
Metanil