/*********************************************
** File: fnSumOfTwoTime.sql
** Name: fnSumOfTwoTime
** Description: 把两个以“小时:分钟:秒钟”的时间相加求和
输入参数必须以24小时格式来表示且不能为“24:00:00”
** Return values: varchar(20)
** Parameters: @dtmStart,@dtmEnd
** Author: 何毅翔(MyGodness)
** Date: 2005-4-6
** Use method: select dbo.fnSumOfTwoTime('9:00:00','13:15:22')
***********************************************/
Create function fnSumOfTwoTime(@a varchar(8),@b varchar(8))
returns varchar(20)
As
Begin
declare @sum datetime
select @sum=convert(datetime,@a)+convert(datetime,@b)
return cast(cast(day(@sum)-1 as int)*24+DATEPART(hh,@sum) as varchar)+':'+cast(DATEPART(n,@sum) as varchar)+':'+cast(DATEPART(s,@sum) as varchar)
End