标签:
ALTER function [dbo].[GetHour](@dt1 datetime,@dt2 datetime)
returns varchar(30)
as
begin
declare @ch as varchar(30)
declare @mins as int
select @mins =(SELECT datediff( MINUTE, @dt1 , @dt2))
if @mins>= 30 and @mins< 60
begin
set @ch = ‘0.5 H‘
end
else if @mins>= 60 and @mins<90
begin
set @ch = ‘1 H‘
end
else if @mins>= 90 and @mins<120
begin
set @ch = ‘1.5 H‘
end
else if @mins>= 120 and @mins<150
begin
set @ch = ‘2 H‘
end
else if @mins>= 150 and @mins<180
begin
set @ch = ‘2.5 H‘
end
else if @mins>= 180 and @mins<210
begin
set @ch = ‘3 H‘
end
else if @mins>= 210 and @mins<240
begin
set @ch = ‘3.5 H‘
end
else if @mins>= 240 and @mins<270
begin
set @ch = ‘4 H‘
end
else if @mins>= 270 and @mins<300
begin
set @ch = ‘4.5 H‘
end
else if @mins>= 300 and @mins<330
begin
set @ch = ‘5 H‘
end
else
begin
set @ch = @mins
end
return @ch
end
通过时间相差的分钟数,得出加班半小时,1小时,1.5不时,2小时等..
标签:
原文地址:http://www.cnblogs.com/szlixin/p/4335433.html