Reputation: 117
I have a database project that I have to insert some music information in it. In one of my tables, I have a column in which I have to insert the track time of all the songs. For that, I was wondering if there is any function (similar to to_date()
) that I can use in order to insert minute:second format only.
I tried to use to_timestamp()
. However, it will always give me actual date with the first day of the month that I insert the data.
for example:
to_timestamp('9:10','MI:SS')
Result:
18-06-01, 00:9:10,0000000
PS: for the track time column, is it ok to defined the datatype as TIMESTAMP?
Upvotes: 0
Views: 1348
Reputation: 1269603
Oracle doesn't support a separate time
data type.
I would suggest that you store the value as a number of seconds if you want to do arithmetic (such as adding up the values). If you just want to look at them, use a string format.
If you want to convert a number of seconds to minutes/seconds, you can use:
select floor(secs / 60) || ':' || lpad(mod(secs, 60), 2, '0')
Upvotes: 3