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