Alex McManns Alex McManns - 1 year ago 72
SQL Question

Is there a formula to convert minutes to hours? (not division by 60)

Is there a way to convert minutes to hours?

Like I have a 405 minutes, how can I get 6H45 or 6,45 hours out of it?

If I do 405/60 it gives me 6,75.

But I want 6,45.

I need it in my SQL query. Thank you in anvace.

Answer Source

You can calculate Hours and minutes separately and concatenate the valueS like below

SELECT CONVERT(VARCHAR(10),ROUND(405/60,0)) + 'Hrs ' + CONVERT(VARCHAR(10),CEILING(405%60)) + 'mins'

This will give you 6Hrs 45mins

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download