View previous topic :: View next topic
|
Author |
Message |
Khurshid_Khan
New User
Joined: 21 Feb 2020 Posts: 2 Location: usa
|
|
|
|
Hi,
I have a 6-digit date field as YYMMDD in column 2 of input file. The requirement is to sort the file and OMIT any records with date less than current date. I can use the Y2T for my input data but I cannot find the date variable in SyncSort representative of the YYMMDD. Any help is appreciated. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
One way is,
Code: |
//SORTIN DD *
D200219
D200221
D200222
D200217
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(2,6,ZD,A)
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:DATE1))
OUTFIL REMOVECC,FNAMES=SORTOUT,
BUILD=(1,7),INCLUDE=(2,6,ZD,LT,83,6,ZD) |
output:
Code: |
*********
D200217
D200219
********* |
|
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1337 Location: Bamberg, Germany
|
|
|
|
Code: |
//DATEDIFF EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
D200219
D200221
D200222
D200217
D991231
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(81:DATE1,81:2,6,Y2T,DATEDIFF,81,8,Y4T))
SORT FIELDS=(81,8,SFF,A)
OUTFIL FNAMES=(SORTOUT),
INCLUDE=(81,8,SFF,LT,+0), * anything at least one day old here?
BUILD=(1,7)
/* |
Output:
Code: |
D991231
D200217
D200219 |
|
|
Back to top |
|
|
Khurshid_Khan
New User
Joined: 21 Feb 2020 Posts: 2 Location: usa
|
|
|
|
Thank you much. Let me try this on my own. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
Joerg, Why add extra DATEDIFF when we can avoid it ? |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1337 Location: Bamberg, Germany
|
|
|
|
@Rohit: It's intended for interested parties to see a different approach. |
|
Back to top |
|
|
|