I am trying to make date and time from the oracle select query as follows.
SELECT TO_CHAR(TO_DATE('230201'||''||'1529', 'YYMMDD HH24MI') , 'YYYY-MM-DD HH24:MI') FROM DUAL;
It returns the below result and it's OK.
2023-02-01 15:29
But when I try the same query with 23 or less minutes It returns the wrong result
SELECT TO_CHAR(TO_DATE('230201'||''||'1523', 'YYMMDD HH24MI') , 'YYYY-MM-DD HH24:MI') FROM DUAL;
2302-01-15 23:00
Where is the Wrong point of my query?
CodePudding user response:
That's because you used wrong format model. There's no space between date and time component:
SQL> select to_char(to_date('230201' ||''|| '1523', 'yymmddhh24mi'), 'yyyy-mm-dd hh24:mi') result
2 from dual; ----
here
RESULT
----------------
2023-02-01 15:23
SQL>