====== pears.weekmonthstartdate ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create function "pears"."weekmonthstartdate"(
/* Application Maintained Function / Procedure - DO NOT EDIT*/
in "perd" integer,in "worm" char(1) )
returns date
begin
declare "rv" date;
declare "w" integer;
declare "y" integer;
set "y" = "truncnum"("perd",-2);
set "w" = "perd"-"y";
set "y" = "y"/100;
if "worm" = 'W' then
return "weekenddate"("y","w")-6
end if;
set "rv" = "dateadd"("month",(select "monthoneoffset" from "params"),"ymd"("y","w",1));
return("rv")
end