'How to convert seconds to hours in MySQL

I need to convert seconds to hours in decimal format in MySQL. For example: 150 minutes is 2.5 hours, 75 minutes is 1.25 hours.

I can't see Apache SuperSet supporting HH:mm format, so I think the decimal format would be a better fit. Is there any way built-in way for this conversion?



Solution 1:[1]

To convert 150 minutes to 2.5 one can use:

select 150*60 / 3600.0;

output: 2.5000

First you need to multiply the number of minutes to get the number of seconds (like stated in the question title), and then you can divide by 3600 (which is 60*60).

The short way is to do: SELECT 150/60;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Luuk