this is tabel whose time column need to be sumup..
this is the result..

ans this is the sql script.
declare @tmpTable Table(AH varchar(20))
insert into @tmpTable values('7:30')
insert into @tmpTable values('2:30')
select * from @tmpTable
declare @Minutes as float
declare @Hours as float
declare @HoursFromMunite as Float
select @Hours=sum(cast (substring(AH,0,CHARINDEX(':',AH)) as int)),@Minutes= sum(cast( substring(AH,CHARINDEX(':',AH)+1,len(AH)) as int)) from @tmpTable
set @HoursFromMunite=Floor(@Minutes/60)
set @Hours=@Hours+@HoursFromMunite
if(@HoursFromMunite>0)
set @Minutes= ((@Minutes/60)-@HoursFromMunite)*60
select cast(@Hours as varchar(5))+':'+cast(@Minutes as varchar(5)) as Total
Thanks.

No comments:
Post a Comment
Comments posted on ASP.Net Ajax Tutorials Blog are moderated and will be approved only if they are on-topic and not abusive. Please email me or my team for tech-support or blogging related questions. Avoid including website URLs in your comments - Thanks Author