I hear what you're saying and in fact this is not specifically for a user requirement. It came out of some analysis I was doing and I just wanted to make sure that I haven't missed the DATE1(-)-1year function
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
joeempson,
Use the following DFSORT JCL which will give you the desired results. I assumed that your input is FB recfm and LRECL=80
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
2008-10-01 RECORD 01
2009-10-02 RECORD 02
2010-12-03 RECORD 03
2011-05-05 RECORD 04
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC OVERLAY=(81:DATE1,81,8,Y4T,SUBYEARS,+1,TOGREG=Y4T(-))
OUTFIL BUILD=(1,80),INCLUDE=(1,10,CH,GE,89,10,CH)
//*
SUBYEARS function subtracts n years from the p,m,Yxx date field. If the resulting date is February 29 of a non-leap year, it will be adjusted backwards to a valid date of February 28. ex :