DATE Comparision
Posted:
Mon Jan 31, 2011 8:50 pm
by RajeshT
Good Morning !!
Can you help me comparing a DATE from a flat file to a fixed date. I have 6 byte date field in the form of MMDDYY at position 1 in the file. I wanted to remove all the records with the DATE greater than 01st OCT 2010.
Thank you.
Rajesh.
Re: DATE Comparision
Posted:
Tue Feb 08, 2011 6:22 pm
by RajeshT
Can someone comment on DATE comparison please.
Thank you.
Rajesh.
Re: DATE Comparision
Posted:
Tue Feb 08, 2011 7:55 pm
by Robert Sample
What do you want comment on? It is obvious the comparison has to be done in two parts -- year first, then month and day since the format is MMDDYY. Date comparisons is one reason so many dates are stored in YYMMDD format. Have you searched the forum for solutions? Have you used Google to find solutions? There are plenty of examples of how to do this --- even in Syncsort -- available if you look.
Re: DATE Comparision
Posted:
Wed Feb 09, 2011 2:21 am
by Alissa Margulies
Here is one example of how to accomplish this task:
//SORT1 EXEC PGM=SORT,PARM='CENTWIN=80'
//SORTIN DD *
120109
041810
100110
082211
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
INREC OVERLAY=(10:5,2,1,4)
SORT FIELDS=COPY
OUTFIL INCLUDE=(10,6,Y2T,LE,101001),BUILD=(1,6)
/*
Here is the output produced:
Re: DATE Comparision
Posted:
Wed Feb 09, 2011 2:27 am
by Alissa Margulies
Here is a more efficient method:
//SORT1 EXEC PGM=SORT,PARM='CENTWIN=80'
//SORTIN DD *
120109
041810
100110
082211
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OMIT COND=(5,2,Y2C,GT,10,OR,(5,2,Y2C,EQ,10,AND,1,4,ZD,GT,1001))
SORT FIELDS=COPY
/*
Re: DATE Comparision
Posted:
Wed Feb 23, 2011 6:40 pm
by RajeshT
Thank You very much Alissa. The code you've mentioned below worked for me. However, i have tried the code pasted below earlier and it too had given the expected result :- created the 4 digit year and them performed the comparison.
INREC IFTHEN=(WHEN=(63,2,CH,GT,C'11'),
OVERLAY=(65:63,2,63:C'19'),HIT=NEXT),
IFTHEN=(WHEN=(63,2,CH,LE,C'11',&,63,2,CH,GE,C'00'),
OVERLAY=(65:63,2,63:C'20'),HIT=NEXT),
IFTHEN=(WHEN=(59,6,CH,EQ,C' '),
OVERLAY=(59:C' '))
SORT FIELDS=COPY
Thank You for the help.
Rajesh.