I have dates like this and I want to convert those short month names into numbers.
Sep 30 2021 19:00:04 08
My desired output is either one of them.
2021/30/09 19:00:04 or 20213009190004
CodePudding user response:
One option
SQL> with x ( string ) as ( select 'Sep 30 2021 19:00:04 08' from dual )
2 select to_char(to_date(substr(string,0,length(string) - 3),'Mon DD YYYY HH24:MI:SS'),'YYYY/MM/DD HH24:MI:SS') from x ;
TO_CHAR(TO_DATE(SUB
-------------------
2021/09/30 19:00:04
SQL> with x ( string ) as ( select 'Sep 30 2021 19:00:04 08' from dual )
2 select to_char(to_date(substr(string,0,length(string) - 3),'Mon DD YYYY HH24:MI:SS'),'YYYYMMDDHH24MISS') from x ;
TO_CHAR(TO_DAT
--------------
20210930190004