I have all the dates inserted into the table as varchar2 (10) and formatted as 'mm / dd / yyyy'. I need the following format "mm-dd-yyyy" and the date data type. My implementation without PLSQL will be:
select day||'-'||month||'-'||year as formatted_date from (select extract( day from (select to_date('1/21/2000','mm/dd/yyyy') from dual)) as day, to_number(extract( month from (select to_date('1/21/2000','mm/dd/yyyy') from dual)),09) as month, extract( year from (select to_date('1/21/2000','mm/dd/yyyy') from dual)) as year from dual);
code>
Result: 21-1-2000 is not 21-01-2000 as expected.
When adding extra to_date (,) like:
to_date(day||'-'||month||'-'||year,'DD-MM-YYYY') as formatted_date
he does not even change the field of the day and month with eachother.
source share