时间工时累加

方案一: 更灵活,可以继续具体下去。

 

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

posted @ 2013-05-04 11:49  忙碌在路上  阅读(229)  评论(0编辑  收藏  举报