SQL Convert Milliseconds to Days, Hours, Minutes
I need convert a millisecond value, 85605304.3587 to a value like 0d 18h 21m. No idea on how to start that, is there something similar to a TimeSpan in SQL like there is in C#? You can do the calculation explicitly. I think it is: select floor(msvalue / (1000 * 60 * 60 * 24)) as days, floor(msvalue / (1000 * 60 * 60)) % 24 as hours, floor(msvalue / (1000 * 60)) % 60 as minutes Note: Some databases use mod instead of % . In MS SQL SERVER you can use next code: with cte as ( select cast(85605304.3587 as int) / 1000 / 60 as [min] ), cte2 as ( select cast([min] % 60 as varchar(max)) as minutes,