Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Calculate difference between two gregorian dates.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
gabriel.ryoga

New User


Joined: 07 Jun 2007
Posts: 31
Location: Spain

PostPosted: Mon Apr 27, 2009 6:37 pm    Post subject: Calculate difference between two gregorian dates.
Reply with quote

I need a sort card to calculate the difference (in days) between to gregorian dates, the dates are in YYYYMMDD.

Input:
Code:

2009100120091002
2009110120091110


Output:
Code:

1
9


Is this possible or I need first to convert the gregorian dates to julian dates??.

Thanks for the help.
Back to top
View user's profile Send private message

Skolusu

Senior Member


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

PostPosted: Tue Apr 28, 2009 12:48 am    Post subject:
Reply with quote

gabriel.ryoga,

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
2009100120091002
2009110120091110
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  SORT FIELDS=COPY
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(97:1,4,3C'0',9,4,3C'0')),
  IFTHEN=(WHEN=INIT,OVERLAY=(81:01,04,ZD,MOD,+4,EDIT=(T),
                             82:01,04,ZD,MOD,+100,EDIT=(TTT),
                             85:01,04,ZD,MOD,+400,EDIT=(TTT),
                             88:09,04,ZD,MOD,+4,EDIT=(T),
                             89:09,04,ZD,MOD,+100,EDIT=(TTT),
                             92:09,04,ZD,MOD,+400,EDIT=(TTT))),
  IFTHEN=(WHEN=(85,3,ZD,EQ,0,OR,(81,1,ZD,EQ,0,AND,82,3,ZD,GT,0)),
  OVERLAY=(95:C'L'),HIT=NEXT),
  IFTHEN=(WHEN=(92,3,ZD,EQ,0,OR,(88,1,ZD,EQ,0,AND,89,3,ZD,GT,0)),
  OVERLAY=(96:C'L'),HIT=NEXT),

  IFTHEN=(WHEN=(05,02,ZD,EQ,01),
  OVERLAY=(101:07,2,ZD,EDIT=(TTT)),HIT=NEXT),
  IFTHEN=(WHEN=(13,02,ZD,EQ,01),
  OVERLAY=(108:15,2,ZD,EDIT=(TTT)),HIT=NEXT),

  IFTHEN=(WHEN=(05,02,ZD,EQ,02),
  OVERLAY=(101:+031,ADD,07,02,ZD,EDIT=(TTT)),HIT=NEXT),
  IFTHEN=(WHEN=(13,02,ZD,EQ,02),
  OVERLAY=(108:+031,ADD,15,02,ZD,EDIT=(TTT)),HIT=NEXT),

  IFTHEN=(WHEN=(05,02,ZD,EQ,03),
  OVERLAY=(101:+059,ADD,07,02,ZD,EDIT=(TTT)),HIT=NEXT),
  IFTHEN=(WHEN=(13,02,ZD,EQ,03),
  OVERLAY=(108:+059,ADD,15,02,ZD,EDIT=(TTT)),HIT=NEXT),

  IFTHEN=(WHEN=(05,02,ZD,EQ,04),
  OVERLAY=(101:+090,ADD,07,02,ZD,EDIT=(TTT)),HIT=NEXT),
  IFTHEN=(WHEN=(13,02,ZD,EQ,04),
  OVERLAY=(108:+090,ADD,15,02,ZD,EDIT=(TTT)),HIT=NEXT),

  IFTHEN=(WHEN=(05,02,ZD,EQ,05),
  OVERLAY=(101:+120,ADD,07,02,ZD,EDIT=(TTT)),HIT=NEXT),
  IFTHEN=(WHEN=(13,02,ZD,EQ,05),
  OVERLAY=(108:+120,ADD,15,02,ZD,EDIT=(TTT)),HIT=NEXT),

  IFTHEN=(WHEN=(05,02,ZD,EQ,06),
  OVERLAY=(101:+151,ADD,07,02,ZD,EDIT=(TTT)),HIT=NEXT),
  IFTHEN=(WHEN=(13,02,ZD,EQ,06),
  OVERLAY=(108:+151,ADD,15,02,ZD,EDIT=(TTT)),HIT=NEXT),

  IFTHEN=(WHEN=(05,02,ZD,EQ,07),
  OVERLAY=(101:+181,ADD,07,02,ZD,EDIT=(TTT)),HIT=NEXT),
  IFTHEN=(WHEN=(13,02,ZD,EQ,07),
  OVERLAY=(108:+181,ADD,15,02,ZD,EDIT=(TTT)),HIT=NEXT),

  IFTHEN=(WHEN=(05,02,ZD,EQ,08),
  OVERLAY=(101:+212,ADD,07,02,ZD,EDIT=(TTT)),HIT=NEXT),
  IFTHEN=(WHEN=(13,02,ZD,EQ,08),
  OVERLAY=(108:+212,ADD,15,02,ZD,EDIT=(TTT)),HIT=NEXT),

  IFTHEN=(WHEN=(05,02,ZD,EQ,09),
  OVERLAY=(101:+243,ADD,07,02,ZD,EDIT=(TTT)),HIT=NEXT),
  IFTHEN=(WHEN=(13,02,ZD,EQ,09),
  OVERLAY=(108:+243,ADD,15,02,ZD,EDIT=(TTT)),HIT=NEXT),

  IFTHEN=(WHEN=(05,02,ZD,EQ,10),
  OVERLAY=(101:+273,ADD,07,02,ZD,EDIT=(TTT)),HIT=NEXT),
  IFTHEN=(WHEN=(13,02,ZD,EQ,10),
  OVERLAY=(108:+273,ADD,15,02,ZD,EDIT=(TTT)),HIT=NEXT),

  IFTHEN=(WHEN=(05,02,ZD,EQ,11),
  OVERLAY=(101:+304,ADD,07,02,ZD,EDIT=(TTT)),HIT=NEXT),
  IFTHEN=(WHEN=(13,02,ZD,EQ,11),
  OVERLAY=(108:+304,ADD,15,02,ZD,EDIT=(TTT)),HIT=NEXT),

  IFTHEN=(WHEN=(05,02,ZD,EQ,12),
  OVERLAY=(101:+334,ADD,07,02,ZD,EDIT=(TTT)),HIT=NEXT),
  IFTHEN=(WHEN=(13,02,ZD,EQ,12),
  OVERLAY=(101:+334,ADD,15,02,ZD,EDIT=(TTT)),HIT=NEXT),

  IFTHEN=(WHEN=(95,1,CH,EQ,C'L',AND,05,2,ZD,GT,2),
  OVERLAY=(101:+1,ADD,101,03,ZD,EDIT=(TTT)),HIT=NEXT),
  IFTHEN=(WHEN=(96,1,CH,EQ,C'L',AND,13,2,ZD,GT,2),
  OVERLAY=(108:+1,ADD,108,03,ZD,EDIT=(TTT)),HIT=NEXT)

  OUTREC BUILD=(1,16,C' DATE DIFFERENCE IS : ',
                104,4,ZD,SUB,97,4,ZD,EDIT=(IIIT),
                C' YEARS AND ',
                108,3,ZD,SUB,101,3,ZD,EDIT=(IIIT),
                C' DAYS ')

/*


The output from this job is

Code:


2009100120091002 DATE DIFFERENCE IS :    0 YEARS AND    1 DAYS
2009110120091110 DATE DIFFERENCE IS :    0 YEARS AND    9 DAYS
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Apr 28, 2009 1:20 am    Post subject:
Reply with quote

What about leap years?
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Apr 28, 2009 1:37 am    Post subject: Reply to: Calculate de difference between two gregorian date
Reply with quote

Craq Giegerich wrote:
What about leap years?


The posted job already considers the leap years . What makes you think it is not considering them?
Back to top
View user's profile Send private message
gabriel.ryoga

New User


Joined: 07 Jun 2007
Posts: 31
Location: Spain

PostPosted: Tue Apr 28, 2009 2:31 pm    Post subject:
Reply with quote

Thankyou very much Skolusu.

That's just what i need.

Thanks again!
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Nov 02, 2010 4:41 am    Post subject:
Reply with quote

gabriel.ryoga,

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----
2009100120091002                                     
2009110120091110                                     
//SORTOUT  DD SYSOUT=*                               
//SYSIN    DD *                                       
  SORT FIELDS=COPY                                   
  INREC OVERLAY=(20:9,8,Y4T,DATEDIFF,1,8,Y4T)         
//*


The output from the above job is

Code:

2009100120091002   +0000001
2009110120091110   +0000009


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
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Difference between TWALENG and TWASIZE Arunkumar Chandrasekaran CICS 3 Tue Jan 03, 2017 12:57 pm
No new posts Sticky: difference between ... DUMMY ... and ... enrico-sorichetti JCL & VSAM 0 Mon Oct 17, 2016 4:31 pm
No new posts How to calculate an specific transact... lind sh CICS 2 Tue Sep 13, 2016 9:20 pm
No new posts Difference space showed for TS and it... autobox DB2 1 Thu Apr 14, 2016 1:07 pm
No new posts Difference Between CICS WebSupport an... sachinji84 CICS 1 Mon Mar 07, 2016 7:25 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us