Show pageOld revisionsBacklinksExport to PDFFold/unfold allBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== pears.dateToNearest ====== <WRAP center round info> Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. </WRAP> ===== Original SQL ===== <code sql> create function "pears"."dateToNearest"( /* Application Maintained Function / Procedure - DO NOT EDIT*/ in "pDate" date,in "pUnit" char(1) ) returns date deterministic begin case "pUnit" when 'd' then return "pDate" when 'w' then while "dow"("pDate") <> 2 loop set "pDate" = "pDate"-1 end loop; return "pDate" when 'm' then return "ymd"("year"("pDate"),"month"("pDate"),1) when 'q' then return "ymd"("year"("pDate"),"floor"(("month"("pDate")-1)/3)*3+1,1) when 'y' then return "ymd"("year"("pDate"),1,1) end case end </code> database/functions/pears_datetonearest.txt Last modified: 2026/08/07 19:24by 127.0.0.1