如何在SQl Server中将小数转换为HH.MM
格式。示例: - 06.85将转换为07.25,06.60将转换为7.00
答案 0 :(得分:0)
SELECT
CASE
WHEN DecimalValue - FLOOR(DecimalValue) >= 0.6 THEN DecimalValue + 1 - 0.6
ELSE DecimalValue
END AS HHMMFormat
FROM
MyTable
显然,+ 1 - 0.6
可以被+ 0.4
替换,但我认为+ 1 - 0.6
更清楚地显示了添加的原因。
答案 1 :(得分:0)
select floor(06.85) + cast(((06.85 - floor(06.85))*100) as int) / 60 + cast((cast((06.85 - floor(06.85)) * 100 as int) % 60) as float) / 100
select floor(06.60) + cast(((06.60 - floor(06.60))*100) as int) / 60 + cast((cast((06.60 - floor(06.60)) * 100 as int) % 60) as float) / 100