文件名称:计算工作时间(sql) fan
文件大小:3KB
文件格式:SQL
更新时间:2012-01-12 17:42:38
计算工作时间
计算工作时间 除去星期天和节假日,自定义班次及上班时间。支持2个班次 请修改里面的 --获取开始时间的绝对值 declare @firstTime datetime, @SecondTime datetime, @thirdTime datetime,@endtime datetime, @daytype int, @day datetime declare @fltAbBeginTime float,@fltAbEndTime float Select @firstTime = firstTime,@SecondTime = SecondTime, @ThirdTime=ThirdTime,@EndTime = EndTime, @dayType = daytype, @day = taday from CalendarTable where taday = Convert(varchar(10), @Abegintime, 121) if (@dayType <> '1') --休息 Set @fltAbBeginTime = 0 else exec @fltAbBeginTime = GetAbsTime @Abegintime, @firstTime, @SecondTime, @ThirdTime, @EndTime --获取结束时间的绝对值 Select @firstTime = firstTime,@SecondTime = SecondTime, @ThirdTime=ThirdTime,@EndTime = EndTime, @dayType = daytype, @day = taday from CalendarTable where taday = Convert(varchar(10), @Abegintime, 121) if (@dayType <> '1') --休息 set @fltAbEndTime = 0 else exec @fltAbEndTime = GetAbsTime @Aendtime, @firstTime, @SecondTime, @ThirdTime, @EndTime --获取中间的差的天数。并计算工作时间