hargurjeet singh
hargurjeet singh

Reputation: 45

SQL: Converting number to time

I have a database column having the following values

column (hh/mm/ss)
042336
050623

Now using sql i want to covert it to like

column
04:23:63:000
05:06:23:000

I have been trying to_date function but no success yet.

Upvotes: 0

Views: 41

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269443

You have a string so you can use string operations to insert the additional characters:

select (substr(x, 1, 2) || ':' || substr(x, 3, 2) || ':' || substr(x, 5, 2) || ':000')
from (select '042336' as x from dual) t

Upvotes: 1

Related Questions