Skip to content
Advertisement

Convert time float to format HH:mm sql server

I need to format a float decimal number into a time format hour:minute.

I wrote this Scalar-Value Functions with an input float and output varchar(6):

It looks like great, but not for everything records. This is my output:

As you can see from the results, there are 3 wrongs conversion: 0.33 = 00:19 // 0.58 = 00:34 // 0.83 = 00:49.

How do I set the correct output?

Advertisement

Answer

Use function FORMAT SQL 2012+ https://learn.microsoft.com/en-us/sql/t-sql/functions/format-transact-sql

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement