Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
bipinpeter

Active User

Joined: 18 Jun 2007
Posts: 213
Location: Cochin/Kerala/India

 Posted: Thu May 29, 2008 7:51 pm    Post subject: Difference between two dates Hi, How to find the difference between two dates throug SORT. My input is like this: 20080501 20080520 Can we get 3 months bfore date of a particular date? Eq: input: 20080101 Output:20071001 Regards, Bipin Peter

Skolusu

Senior Member

Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

 Posted: Thu May 29, 2008 9:36 pm    Post subject: bipinpeter, DFSORT does not have any built-in functions for doing arithmetic on date fields. If your dates are both in the same year then it is very easy to calculate the difference.
Skolusu

Senior Member

Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

Posted: Tue Nov 02, 2010 4:21 am    Post subject: Re: Difference between two dates

 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

 Code: 20080101 20071001

For complete details of date arithmetic functions and other new functions see "User Guide for DFSORT PTFs UK90025 and UK90026" paper (sortugph.pdf) at:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000242
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Difference between EQUAL and EQUAL TO... jithinraghavan COBOL Programming 3 Thu Apr 19, 2018 2:22 am ISMF Difference between volume count ... upendrasri IBM Tools 2 Tue Dec 05, 2017 12:40 pm Comparing dates in different formats migusd SYNCSORT 4 Sat Nov 18, 2017 3:02 am Finding difference between two PS fil... Vignesh Sid SYNCSORT 5 Mon Oct 30, 2017 1:13 pm Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 5 Fri Sep 22, 2017 4:56 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us