I have one file with the two fileds have timestamp .I need to compare the both dates (date format is YYYY/MM/DD), If the date difference is more than one day I need to write one file otherwise I need to write into another file .
Hi,
The record length of the file is 209 and record format is FB,
the first date filed is starting from 49 to 58 and second date filed starting from 128 to 137
I don't know any function within DFSort to do the date difference directly. Since you haven't yet given your DFSort function level, I am assuming you have the latest PTF available...
Check if below works for you...
Code:
//STEP01 EXEC PGM=SORT
//SYSOUS DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD YOUR INPUT FILE
//OUT DD YOUR DATE DIFF. OF 1 FILE
//SAVE DD YOUR REMAINING RECORDS FILE
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(211:049,04,054,02,057,02,2X,221:211,08,Y4T,TOJUL=Y4T,3X,
231:128,04,133,02,135,02,2X,241:231,08,Y4T,TOJUL=Y4T,3X,
251:((((221,04,ZD,SUB,+1901),MUL,+36525),DIV,+100),ADD,
225,03,ZD),TO=ZD,LENGTH=5,5X,
261:((((241,04,ZD,SUB,+1901),MUL,+36525),DIV,+100),ADD,
245,03,ZD),TO=ZD,LENGTH=5,5X,
271:(261,5,ZD,SUB,251,5,ZD),TO=ZD,LENGTH=5))
SORT FIELDS=COPY
OUTFIL FNAMES=OUT,INCLUDE=(271,5,ZD,EQ,+1,OR,
271,5,ZD,EQ,-1),BUILD=(1,209)
OUTFIL FNAMES=SAVE,BUILD=(1,209)
/*
However, using cobol, it gets less complicated. Below is a cobol logic for the same.
Code:
*
COMPUTE WS-CCYYMMDD-N1 = FUNCTION
INTEGER-OF-DATE(WS-CCYYMMDD1) --> your first date field
END-COMPUTE
*
COMPUTE WS-CCYYMMDD-N2 = FUNCTION
INTEGER-OF-DATE(WS-CCYYMMDD2) --> your second date field
END-COMPUTE
*
gvenkateshmca,
Please use updated sort card as below. In the earlier solution,I had a mistake in field positioning and SAVE was missing in the final OUTFIL statement.
However, please note that this formula should only work when the dates are between 1901-01-01 through 2099-12-31.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
gvenkateshmca,
With PTF UK90025 for z/OS DFSORT V1R10 and PTF UK90026 for z/OS DFSORT V1R12(Oct, 2010), DFSORT now supports date arithmetic which can be used to calculate the number of days difference between two dates. The result is an 8-byte value consisting of a sign and 7 digits (sddddddd). If the first date is greater than or equal to the second date, the sign is + (plus). If the first date is less than the second date, the sign is - (minus).
For complete details of date arithmetic functions and other new functions see "User Guide for DFSORT PTFs UK90025 and UK90026" paper (sortugph.pdf) at: