本文介绍了分钟至HH:MM转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格,其中以持续时间"为一列,其中包含分钟总和",我想将其所有持续时间"都转换为HH:MM格式.

ECode 持续时间
101 186
102 1446
103 1116


输出应如下所示:-

ECode 持续时间
101 3.06
102 24.06
103 18.36


我想使用Update语句来执行此操作,并想要更新所有这样的行.
正在寻找可以解决我问题的查询.谢谢.

I have a table which have Duration as a column which contains Sum of Minutes and i want to convert all the Duration it in to HH:MM Format.

ECodeDuration
101186
1021446
1031116


The output should be like this:-

ECodeDuration
1013.06
10224.06
10318.36


I want to do it with an Update statement and want to update all the rows like this .
Looking for the Query which may slve my problem.Thanks in advance.

推荐答案


UPDATE tbFormat
SET Duration =
              (CASE
                   WHEN
                       ((Duration%60)<10)
                   THEN
                       CONVERT(VARCHAR(10),Duration/60)+':'+ CASE WHEN CONVERT(VARCHAR(10),Duration%60)<10 THEN +'0'+CONVERT(VARCHAR(10),Duration%60) END
                   ELSE
                       CONVERT(VARCHAR(10),Duration/60)+':'+CONVERT(VARCHAR(10),Duration%60)
                   END
               )




希望这会有所帮助..

请回复您的评论...




hope this helps..

plz revert back with ur comments...


这篇关于分钟至HH:MM转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 09:31
查看更多