passion_sujesh
New User
Joined: 14 Mar 2008 Posts: 74 Location: India,Chennai
|
|
|
|
Hi all,
I have a requirement in which i have to find the number of years the records are present in the file(from current date). Each record will have a date in the first 10 bytes (mm/dd/yyyy).This date corresponds to when the record was written in the file.The date might vary for each record. I need to find how many years each record is present in the file.
Input file details:
Length : 50 bytes (10 bytes date + 40 bytes data)
Sample record:
10/12/2005.....40 bytes data....
Expected output:
Length: 58 bytes (50 bytes data + 08 bytes date (difference date)) I have to use system date to find the difference date.
difference date format -- yyyymmdd.
Sample o/p record:
50 bytes i/p record..00071002
here '0007' corresponds to number of years the record was present in file.
'10' corresponds to number of months and '02' corresponds to number of days. |
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
passion_sujesh,
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).
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
----+----1----+----2----+----3----+----4----+----5----+----6---
10/12/2005.....40 BYTES DATA....
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFOUTLEN=58,
IFTHEN=(WHEN=INIT,BUILD=(1,50,DATE1,1,10,UFF,M11,LENGTH=8)),
IFTHEN=(WHEN=INIT,OVERLAY=(51:51,8,Y4T,DATEDIFF,59,8,Y4W))
//* |
The output from the above job is
Code: |
10/12/2005.....40 BYTES DATA.... +0001846
|
For complete details of date arithmetic functions and other new functions see "User Guide for DFSORT PTFs UK90025 and UK90026" paper (sortugph.pdf) at:
www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000242 |
|