Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

STRING DATE AND TIME COMBINE AND MAKE FULL DATE TIME IN ORACLE PL/SQL

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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?

>Solution :

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>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading