Home > front end >  Convert minutes into hours in PostgreSQL
Convert minutes into hours in PostgreSQL

Time:01-26

I want to convert 300 minutes into 5 hours.

Input is 300 Output should be 05:00

CodePudding user response:

You can convert it to an interval, and format that usin to_char()

to_char(make_interval(mins => 300), 'HH24:MI')

The FM prefix avoids padding the result with blanks

CodePudding user response:

This one works:

SELECT CAST(300 * INTERVAL '1 minute' AS TIME);
  • Related