Solved

how to change datetime format from dataset and store into oracle

Posted on 2008-06-12
2
1,218 Views
Last Modified: 2013-12-19
Hi expert,

I have the dataset which contains datatime formated  as 12/06/2008 12:00:00, I need to reformat it as 12-June-2008 to store into ORACLE database, otherwise it give me error as ORA-01861: literal does not match format string

can some one give me advise how to solve this issue.

Thanks in advance

Ying
0
Comment
Question by:ying88888
  • 2
2 Comments
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 21773804
Oracle does not store dates in any particular format.

To have Oracle display dates in a specific format, set the NLS_DATE_FORMAT parameter:

ALTER SYSTEM SET NLS_DATE_FORMAT='DD-Month-YYYY';

Open in new window

0
 
LVL 29

Accepted Solution

by:
MikeOM_DBA earned 250 total points
ID: 21773838
...OR Alter session.
If you have an external dataset in a particular format, use the TO_DATE() function to load into an oracle date column:



SQL> ALTER SESSION SET NLS_DATE_FORMAT='DD-Month-YYYY';
 

Session altered.
 

SQL> SELECT TO_DATE('12/06/2008 12:00:00','DD/MM/YYYY HH24:MI:SS') FROM DUAL;
 

TO_DATE('12/06/20

-----------------

12-June-2008
 

SQL> 

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now