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.IQXNetStringToDate ====== <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"."IQXNetStringToDate"( /* Application Maintained Function / Procedure - DO NOT EDIT*/ in "sdate" char(20) ) returns date begin declare "rv" date; declare "i" smallint; declare "d" smallint; declare "m" smallint; declare "y" smallint; set "sdate" = "trim"("sdate"); if "sdate" regexp '^\\d{4}\\-.*' then -- ISO format set "y" = cast("left"("sdate",4) as smallint); set "sdate" = "stuff"("sdate",1,5,''); set "i" = "charindex"('-',"sdate"); if "i" <= 1 then return null end if; set "m" = cast("left"("sdate","i"-1) as smallint); set "sdate" = "stuff"("sdate",1,"i",''); set "d" = cast("sdate" as smallint) else -- UK format with optional preceding day name set "i" = "charindex"(' ',"sdate"); if "i" > 0 then -- Day name to be removed before parsing date set "sdate" = "trim"("stuff"("sdate",1,"i",'')) end if; set "i" = "charindex"('/',"sdate"); if "i" <= 1 then return null end if; set "d" = cast("left"("sdate","i"-1) as smallint); set "sdate" = "stuff"("sdate",1,"i",''); set "i" = "charindex"('/',"sdate"); if "i" <= 1 then return null end if; set "m" = cast("left"("sdate","i"-1) as smallint); set "sdate" = "stuff"("sdate",1,"i",''); set "y" = cast("sdate" as smallint) end if; return "ymd"("y","m","d") exception when others then return null end </code> database/functions/pears_iqxnetstringtodate.txt Last modified: 2026/08/07 19:24by 127.0.0.1