Search code examples
oracle-databaseselecttimevarchar

Conver varchar value as Time in oracle


I have numerical string in varchar column need to return those values in time format

Time
----
1560
1350
1561

output should be like below

time
----
00:15:60
00:13:50
00:15:61

im not good in database..can any one help me to return like this...


Solution

  • 00:15:60 is not a valid hour format... what do you mean? 15minutes and 60seconds? why not use 16minutes instead?

    anyway, after you fix the value of seconds passed in, use the query below

    select
         to_char(
           to_date('001500','HH24MISS')
         ,'HH24:MI:SS')
    from dual;