Let’s suppose I have 2 intervals:
INTERVAL '0 00:30:00' DAY TO SECOND
INTERVAL '0 04:00:00' DAY TO SECOND
What is the most elegant way to get amount of minutes in each interval. 30 and 240 accordingly.
Yes, I know I can perform EXTRACT(HOUR FROM interval) * 60 + EXTRACT(MINUTE FROM interval), but this looks terrible to me.
Any better solutions?
What looks terrible to you, looks perfectly acceptable to me. If you look at the documentation at the arithmetic you can perform on INTERVALs:
http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements001.htm#sthref175
then you see you can multiply them with numerics. So if you multiply your intervals to 24 and 60, you can get the number of minutes by extracting the number of days. It’s more compact, but I doubt if it’s more elegant in your view.
Regards,
Rob.