Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get correct format of the dates?

947663Apr 21 2023

Hi All,

I have data in date format but while loading data from file some dates are loaded wrongly as 21-Apr-0023 rather than 21-Apr-2023. Now how to convert all the rows to correct format of 21-Apr-2023 using to_date function ?

Sample Table is given below:

create table xx_ramesh_temp (hire_date date);

insert into xx_ramesh_temp values (to_date('21-Apr-0023','dd-MON-YYYY'));
insert into xx_ramesh_temp values (to_date('21-Apr-2023','dd-MON-YYYY'));

select to_char(hire_date,'dd-Mon-YYYY'),hire_date from xx_ramesh_temp;

Output currently as below:

21-Apr-0023 21-APR-23
21-Apr-2023 21-APR-23

Thanks,

Ramesh S.

This post has been answered by mathguy on Apr 21 2023
Jump to Answer
Comments
Post Details
Added on Apr 21 2023
8 comments
3,625 views