时间工时累加
方案一: 更灵活,可以继续具体下去。
create table #tt(cc varchar(20))
insert into #tt values('04:10')
insert into #tt values('06:10')
insert into #tt values('21:50')
SELECT LTRIM(dd/3600)+':'+RIGHT(100+dd%3600/60,2)+':'+RIGHT(100+dd%60,2) newcol FROM (SELECT SUM(DATEDIFF(ss,0,cc)) AS dd FROM #tt ) t
drop table #tt
方案二:
insert into #tt values('04:18')
insert into #tt values('06:16')
insert into #tt values('21:52')
select cast(sum(datepart(hh,CONVERT(datetime,cc)))+floor(sum(datepart(minute,CONVERT(datetime,cc)))/60.0) as varchar(10))+':'+
cast(sum(datepart(minute,CONVERT(datetime,cc)))%60 as varchar(10))
from #tt
本文来自博客园,作者:忙碌在路上,转载请注明原文链接:https://www.cnblogs.com/netsa/archive/2013/05/04/3059292.html