我们如何在两次之间制作商店程序?
喜欢,
Total Hr=(( outtime - intime) - (breakin time - breakout time) )
答案 0 :(得分:0)
create procedure sp_time_outtime
@id bigint
as
begin
declare
@totalhour as nvarchar(50),
@tth as bigint,
@ttm as bigint,
@inhour as bigint,
@outhour as bigint,
@breakinhour as bigint select @tth = datediff(mi, intime, (case when breakouttime is null then isnull(breakintime,GETDATE()) else GETDATE() end) ) from time where empid=@id and CONVERT(date,GETDATE()) = CONVERT(date,[date])
select @ttm = datediff(mi, isnull(breakintime,'1/1/1990'),ISNULL(breakouttime,isnull (breakintime,'1/1/1990'))) from time where empid=@id and CONVERT(date,GETDATE()) = CONVERT(date,[date])
select @totalhour = (@tth -@ttm)
SET @totalhour = CASE WHEN (@tth -@ttm) >= 60 THEN (SELECT CAST(((@tth -@ttm) / 60) AS VARCHAR(2)) + ' :H :' +
CASE WHEN ((@tth -@ttm) % 60) > 0 THEN
CAST(((@tth -@ttm) % 60) AS VARCHAR(2)) + ' M'
ELSE
''
END) ELSE
CAST(((@tth -@ttm) % 60) AS VARCHAR(2)) + 'M'
END
if ((select outtime from time where empid=@id and convert(date,GETDATE())=CONVERT(date,[date])) IS NULL)
begin
update time set outtime=GETDATE(),totalhour=@totalhour where
empid=@id and CONVERT(date,GETDATE()) = CONVERT(date,[date])
end END