Converting INT to Hours and Minutes in SQL

110 Views Asked by At

I need to convert and INT such as 125, to hours and minutes which will be 02:05.

I know I can do this in PHP with the following:

date('H:i',mktime(0, 125))

but how do I do this in SQL?

I tried

SEC_TO_TIME(table.minutes*60)

which works but this results in 02:05:00 and I don't want the seconds.

Any ideas?

Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

Use the MySQL TIME_FORMAT function: TIME_FORMAT(SEC_TO_TIME(table.minutes * 60), '%H:%i')