Thursday, February 21, 2019

How to convert number to time format in oracle sql

SQL> variable x number
SQL> exec :x := 123456

PL/SQL procedure successfully completed.

SQL> select lpad(substr(to_char(:x),1,length(to_char(:x))-4),2,'0')||':'||
  2  substr(to_char(:x),-4,2)||':'||
  3  substr(to_char(:x),-2)
  4  from dual;

LPAD(SUBSTR(TO_CHAR(:X),1,
--------------------------
12:34:56

No comments:

Post a Comment

How to install and configure Oracle Apex 24.1 with ORDS 22, Tomcat 9 and Jasper Report 7 on Oracle Linux 8.10

#########################Install Oracle  APEX 24.1################################ ----------------------------------------------------...