====== pears.GetHolidayYear ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create function "pears"."GetHolidayYear"(
/* Application Maintained Function / Procedure - DO NOT EDIT*/
in "startdate" date,in "calcdate" date )
returns date
begin
/*More than a year ago?*/
"SetCurrentYear": loop
if "days"("startdate","calcdate") >= 365 then
set "startdate" = "years"("startdate",1)
else leave "SetCurrentYear"
end if
end loop "SetCurrentYear";
/*Check after regulations startdate*/
if "startdate" < "date"('1998-10-01') then set "startdate" = "date"('1998-10-01')
end if;
return("startdate")
end