I am trying to do some line by line time calculations in a select statement using nested Ifs and i think my syntax is just a bit off. It is failing at the from statement in the last section of the code. please any help would be greatly appreciated.
Code:
CREATE PROCEDURE dbo.svcslr
-- Add the parameters for the stored procedure here
(@callnbr char(11),
@startdate datetime,
@starttime datetime,
@enddate datetime,
@holdtime int output,
@worktime datetime output,
@flag int output,
@workingdate datetime,
@tempstat char(3)
)
as
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
set @workingdate=@startdate+@starttime
set @tempstat='10E'
set @worktime='0'
SELECT [CALLNBR]
,[SRVRECTYPE]
,[LNITMSEQ]
,[FRMSTAT]
,[TOSTAT]
,[TECHID]
,[DSCRIPTN]
,[USERID]
,[CREATDDT]
,[CREATETIME]
,[DEX_ROW_ID]
if (@tempstat='04S' or FRMSTAT='04S')
Begin
if TOSTAT='04S'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='72P'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74I'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74O'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74S'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='75R'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='78M'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='79U'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='80R'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='90I'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
END
if (@tempstat='10E' or FRMSTAT='10E')
Begin
if TOSTAT='04S'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='72P'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74I'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74O'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74S'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='75R'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='78M'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='79U'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='80R'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='90I'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
END
if (@tempstat='20N' or FRMSTAT='20N')
Begin
if TOSTAT='04S'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='72P'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74I'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74O'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74S'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='75R'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='78M'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='79U'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='80R'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='90I'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
END
if (@tempstat='50D' or FRMSTAT='50D')
Begin
if TOSTAT='04S'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='72P'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74I'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74O'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74S'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='75R'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='78M'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='79U'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='80R'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='90I'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
END
if (@tempstat='60A' or FRMSTAT='60A')
Begin
if TOSTAT='04S'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='72P'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74I'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74O'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74S'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='75R'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='78M'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='79U'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='80R'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='90I'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
END
if (@tempstat='65A' or FRMSTAT='65A')
Begin
if TOSTAT='04S'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='72P'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74I'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74O'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74S'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='75R'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='78M'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='79U'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='80R'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='90I'
Begin
set @worktime=@worktime+datediff(n,@workingdate,(creatddt+createtime));
end
END
if (@tempstat='00C' or FRMSTAT='00C')
Begin
if TOSTAT='04S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='72P'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='75R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='78M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='79U'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='80R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='90I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
END
if (@tempstat='30B' or FRMSTAT='30B')
Begin
if TOSTAT='04S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='72P'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='75R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='78M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='79U'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='80R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='90I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
END
if (@tempstat='40M' or FRMSTAT='40M')
Begin
if TOSTAT='04S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='72P'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='75R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='78M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='79U'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='80R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='90I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
END
if (@tempstat='45I' or FRMSTAT='45I')
Begin
if TOSTAT='04S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='72P'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='75R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='78M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='79U'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='80R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='90I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
END
if (@tempstat='50O' or FRMSTAT='50O')
Begin
if TOSTAT='04S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='72P'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='75R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='78M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='79U'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='80R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='90I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
END
if (@tempstat='70C' or FRMSTAT='70C')
Begin
if TOSTAT='04S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='72P'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='75R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='78M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='79U'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='80R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='90I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
END
if (@tempstat='72P' or FRMSTAT='72P')
Begin
if TOSTAT='04S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='72P'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='75R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='78M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='79U'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='80R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='90I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
END
if (@tempstat='74I' or FRMSTAT='74I')
Begin
if TOSTAT='04S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='72P'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='75R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='78M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='79U'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='80R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='90I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
END
if (@tempstat='74O' or FRMSTAT='74O')
Begin
if TOSTAT='04S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='72P'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='75R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='78M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='79U'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='80R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='90I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
END
if (@tempstat='74S' or FRMSTAT='74S')
Begin
if TOSTAT='04S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='72P'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='75R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='78M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='79U'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='80R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='90I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
END
if (@tempstat='75R' or FRMSTAT='75R')
Begin
if TOSTAT='04S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='72P'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='75R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='78M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='79U'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='80R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='90I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
END
if (@tempstat='78M' or FRMSTAT='78M')
Begin
if TOSTAT='04S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='72P'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='75R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='78M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='79U'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='80R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='90I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
END
if (@tempstat='79U' or FRMSTAT='79U')
Begin
if TOSTAT='04S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='72P'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='75R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='78M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='79U'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='80R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='90I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
END
if (@tempstat='80R' or FRMSTAT='80R')
Begin
if TOSTAT='04S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='72P'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='74S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='75R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='78M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='79U'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='80R'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='90I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
END
if (@tempstat='90I' or FRMSTAT='90I')
Begin
if TOSTAT='04S'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='10E'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='20N'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50D'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='60A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='65A'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='00C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='30B'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='40M'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='45I'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='50O'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end
if TOSTAT='70C'
Begin
set @holdtime=@holdtime+datediff(n,@workingdate,(creatddt+createtime));
end