Okay this program is a house of cards but a good start example
call @@SQL parm(20051225 '*ISO' ' ' ' ')
returns Sunday, December 25, 2005
other formats may fail cuz thats how I roll !!!
call @@SQL parm(20051225 '*ISO' ' ' ' ')
returns Sunday, December 25, 2005
other formats may fail cuz thats how I roll !!!
Code:
d @@SQL PR extpgm('@@SQL') d DateIn 15P 5 d DateFormat 05 d StringOut 30 d InvalidDate 1 d @@SQL PI d DateIn 15P 5 d DateFormat 05 d StringOut 30 d InvalidDate 1 D WD DS Qualified D WorkDate155 15 5 D WorkDate6 6 0 OVERLAY(WorkDate155:5) D WorkDate7 7 0 OVERLAY(WorkDate155:4) D WorkDate8 8 0 OVERLAY(WorkDate155:3) d ISODate s D *============================================================= * M A I N L I N E *============================================================= * /free WD.WorkDate155 = DateIn; select; when dateformat = '*ISO'; test(de) *iso WD.Workdate8; if not%error; IsoDate = %date(WD.WorkDate8); else; InvalidDate = 'Y'; endif; when dateformat = '*MDY'; test(de) *mdy WD.WorkDate6; if not%error; IsoDate = %date(WD.WorkDate6:*MDY); else; InvalidDate = 'Y'; endif; when dateformat = '*YMD'; test(de) *ymd WD.Workdate6; if not%error; IsoDate = %date(WD.WorkDate6:*YMD); else; InvalidDate = 'Y'; endif; when dateformat = '*CYMD'; test(de) *cymd WD.Workdate7; if not%error; IsoDate = %date(WD.WorkDate7:*CYMD); else; InvalidDate = 'Y'; endif; other; if %Subdt(ISODate:*Y) < 1940; InvalidDate = 'Y'; endif; endsl; if InvalidDate <> 'Y' ; /end-free * c/exec sql C+ SELECT DAYNAME(:Isodate) || ', ' || MONTHNAME(:Isodate) || ' ' || C+ DAY(:Isodate) || ', ' || YEAR(:Isodate) as longdate INTO C+ :Stringout from SYSIBM/SYSDUMMY1 c/end-exec * /free if StringOut <> *blanks; dsply Stringout; else; Stringout = 'Invalid Date Entered'; dsply Stringout; endif; endif; *inlr = *on; /end-free *
Comment