Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the date format from MM/DD/YYYY to YYYY-MM-DD in PL/SQL?

Tags:

I have a date column in a table stored as MM/DD/YYYY format. I have to select and store the same date in another table in YYYY-MM-DD format i.e. XSD Date Format. But I am not able to do it. I am using this query:

select to_date(date_column,'YYYY-MM-DD') from table; 

But still I am not able to do it. Giving me error

ORA-01843 : not a valid month

like image 619
user972548 Avatar asked Sep 30 '11 06:09

user972548


People also ask

How do I change the date format in PL SQL?

Finally, you can change the default DATE format of Oracle from "DD-MON-YY" to something you like by issuing the following command in sqlplus: alter session set NLS_DATE_FORMAT='<my_format>'; The change is only valid for the current sqlplus session.

How do I change date format from YYYY-MM-DD in Oracle?

To set the date format: Select Preferences in the left frame, or select File, and then Preferences. Click the Planning icon, and then select Display Options. For Date Format, select MM-DD-YYYY, DD-MM-YYYY, YYYY-MM-DD, or Automatically Detect (to use your system's locale settings).

How do I save a date in YYYY-MM-DD in Oracle?

The TO_DATE function allows you to define the format of the date/time value. For example, we could insert the '3-may-03 21:02:44' value as follows: insert into table_name (date_field) values (TO_DATE('2003/05/03 21:02:44', 'yyyy/mm/dd hh24:mi:ss')); Learn more about the TO_DATE function.


1 Answers

use

select to_char(date_column,'YYYY-MM-DD') from table; 
like image 106
Yahia Avatar answered Oct 20 '22 20:10

Yahia