pears.weekmonthstartdate

Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.

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
  • database/functions/pears_weekmonthstartdate.txt
  • Last modified: 2026/08/07 19:24
  • by 127.0.0.1