select dbo.to_hour(SUM(6666.008888))
上面的select语句给出的持续时间为-* h 6m(to_hour函数只接受int但我的duration列是FLOAT
数据类型。)
但我想要time as -111h 1m
请告诉他们如何转换它
答案 0 :(得分:1)
试试这个答案:
SELECT LEFT(CAST((6666.008888)/60 AS VARCHAR),CHARINDEX('.',CAST((6666.008888)/60 AS VARCHAR))-1) + 'h'
+' '+SUBSTRING(CAST((6666.008888)/60 AS VARCHAR),CHARINDEX('.',CAST((6666.008888)/60 AS VARCHAR))+1,1) + 'm'
<强> OR 强>
DECLARE @Value NUMERIC(15,8)=6666.008888
SELECT LEFT(CAST((@Value)/60 AS VARCHAR),CHARINDEX('.',CAST((@Value)/60 AS VARCHAR))-1) + 'h'
+' '+SUBSTRING(CAST((@Value)/60 AS VARCHAR),CHARINDEX('.',CAST((@Value)/60 AS VARCHAR))+1,1) + 'm'
<强>输出:强>
111h 1m