Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
bipinpeter wrote: |
Hi,
How to find the difference between two dates throug SORT.
My input is like this: 20080501 20080520 |
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----+--
20080501 20080520
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC OVERLAY=(20:10,8,Y4T,DATEDIFF,1,8,Y4T)
//* |
The output from the above job is
Code: |
20080501 20080520 +0000019
|
bipinpeter wrote: |
Can we get 3 months bfore date of a particular date?
Eq: input: 20080101
Output:20071001
Regards,
Bipin Peter |
DFSORT now also supports adding/subtracting days/months/years from a date very easily like shown below
Code: |
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
----+----1----+----2----+----3----+----4----+----5----+-
20080101
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC OVERLAY=(10:1,8,Y4T,SUBMONS,+3,TOGREG=Y4T)
//* |
The output from this job is
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 |
|