i have multiple records workinghours of employee as
02:10:00 03:00:00 12:00:00 12:34:56 now need add these record , want display in
`hh:mm:ss` format. used following query works when sum of record less 24 hours record may greater 24 hours.
select cast(dateadd(millisecond, sum(datediff(millisecond, '00:00:00.000' , cast(workhrs time))), '00:00:00.000') time) total_time tblattend i spend more 4 hours on google find solution got no success anymore.
datatype of workinghour column varchar .
the time data type has explicit range 24 hours (see here).
so, think stuck doing conversion yourself. ugly, looks like:
select right('00' + cast(sum(datediff(millisecond, '00:00:00.000', cast(workhrs time))), '00:00:00.000')/(60*60) varchar(255)), 2) ) + right('00' + cast((sum(datediff(millisecond, '00:00:00.000', cast(workhrs time))), '00:00:00.000')/60 % 60) varchar(255)), 2) + right('00' + cast(sum(datediff(millisecond, '00:00:00.000', cast(workhrs time))), '00:00:00.000') % 60 varchar(255)), 2) )
Comments
Post a Comment