====== pears.AddRecoveryHours ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create function "pears"."AddRecoveryHours"(
/* Application Maintained Function / Procedure - DO NOT EDIT*/
in "tfrom" time,in "tto" time,in "hrs" smallint )
returns time
begin
declare "rv" time;
if "isnull"("hrs",0) <= 0 or "tfrom" is null or "tto" is null then
return "tto"
end if;
if "hrs" > 23 then
set "hrs" = 23
end if;
set "rv" = "dateadd"("hour","hrs","tto");
if "rv" < "tto" and "rv" >= "tfrom" then
set "rv" = "dateadd"("minute",-1,"tfrom")
end if;
return "rv"
end