pears.DateAndTimeOverLap
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
Original SQL
CREATE FUNCTION "pears"."DateAndTimeOverLap"( /* Application Maintained Function / Procedure - DO NOT EDIT*/ IN "s1d" DATE,IN "s1t1" TIME,IN "s1t2" TIME,IN "s2d" DATE,IN "s2t1" TIME,IN "s2t2" TIME ) RETURNS tinyint BEGIN DECLARE "rv" tinyint; DECLARE "s1f" TIMESTAMP; DECLARE "s1t" TIMESTAMP; DECLARE "s2f" TIMESTAMP; DECLARE "s2t" TIMESTAMP; SET "rv" = 0; IF "s1t1" IS NULL THEN SET "s1t1" = '00:00:00' END IF; IF "s2t1" IS NULL THEN SET "s2t1" = '00:00:00' END IF; IF "s1t2" IS NULL THEN SET "s1t2" = '23:59:59' END IF; IF "s2t2" IS NULL THEN SET "s2t2" = '23:59:59' END IF; SET "s1f" = "s1d"+"s1t1"; SET "s1t" = "s1d"+"s1t2"; SET "s2f" = "s2d"+"s2t1"; SET "s2t" = "s2d"+"s2t2"; IF "s1t" <= "s1f" THEN SET "s1t" = "dateadd"("day",1,"s1t") END IF; IF "s2t" <= "s2f" THEN SET "s2t" = "dateadd"("day",1,"s2t") END IF; IF "s1f" < "s2t" AND "s1t" > "s2f" THEN SET "rv" = 1 END IF; RETURN "rv" END