IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Difference between dates in European format


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Mar 19, 2013 8:27 pm
Reply with quote

Trying to find the difference between two dates in European format.

I've had a google and a search of the forum but can't seem to find the correct format to use for the datediff functionality.

Any clues, pointers appreciated.

Input
Code:

22/01/2013   24/03/2013
14/01/2011   24/03/2013
30/01/2013   31/03/2013
17/02/2013   31/03/2013

Output - Where nnnn is the days difference between the two dates
Code:

22/01/2013   24/03/2013 nnnn
14/01/2011   24/03/2013 nnnn
30/01/2013   31/03/2013 nnnn
17/02/2013   31/03/2013 nnnn
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Tue Mar 19, 2013 9:14 pm
Reply with quote

How about reformatting the date, calculating the difference and then losing the reformatted date? Along the lines:


Code:
//SORT EXEC PGM=ICEMAN                                         
//SYSOUT DD SYSOUT=*                                           
//SORTIN DD *                                                   
22/01/2013   24/03/2013                                         
14/01/2011   24/03/2013                                         
30/01/2013   31/03/2013                                         
17/02/2013   31/03/2013                                         
//SORTOUT DD SYSOUT=*                                           
//SYSIN DD *                                                   
*                                                               
 OPTION COPY                                                   
*                                                               
 INREC OVERLAY=(51:7,4,55:4,2,57:1,2,60:20,4,64:17,2,66:14,2,   
           25:51,8,Y4T,DATEDIFF,60,8,Y4T)                       
*                                                               
 OUTREC BUILD=(1,50,80:X)                                       
*                                                               



results:


Code:
********************************* TOP OF DATA ****
22/01/2013   24/03/2013 -0000061                 
14/01/2011   24/03/2013 -0000800                 
30/01/2013   31/03/2013 -0000060                 
17/02/2013   31/03/2013 -0000042                 
******************************** BOTTOM OF DATA **


Garry
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Mar 19, 2013 9:34 pm
Reply with quote

Well, similar:

Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SORTOF01 DD SYSOUT=*
//SORTOF02 DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,
          OVERLAY=(30:4,2,1,2,7,4,17,2,14,2,20,4, dates to ddmmyyyy at 30:
                   25:30,8,Y4W,DATEDIFF,38,8,Y4W, datediff, 8, leading sign, at 25:
                   26:26,7,ZD,EDIT=(TTTT),51X)) use last 4 of 8 at 25: preserving sign
//SORTIN   DD *
22/01/2013   24/03/2013
14/01/2011   24/03/2013
30/01/2013   31/03/2013
17/02/2013   31/03/2013
22/01/2016   24/03/2013
14/01/2014   24/03/2013
30/01/2016   31/03/2013
17/02/2016   31/03/2013


Gives:

Code:
22/01/2013   24/03/2013 -0061
14/01/2011   24/03/2013 -0800
30/01/2013   31/03/2013 -0060
17/02/2013   31/03/2013 -0042
22/01/2016   24/03/2013 +1034
14/01/2014   24/03/2013 +0296
30/01/2016   31/03/2013 +1035
17/02/2016   31/03/2013 +1053
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Mar 20, 2013 1:41 am
Reply with quote

expat,

As Gary and Bill mentioned you can reformat the date using INREC and calculate the date difference. I assumed your LRECL=80 and RECFM=FB. IFOUTLEN=n is good choice to remove the temp fields after we are done with the calculations.

Code:

//STEP0100 EXEC PGM=SORT                     
//SYSOUT   DD SYSOUT=*                       
//SORTIN   DD *                             
22/01/2013   24/03/2013                     
14/01/2011   24/03/2013                     
30/01/2013   31/03/2013                     
17/02/2013   31/03/2013                     
//SORTOUT  DD SYSOUT=*                       
//SYSIN    DD *                             
  OPTION COPY                               
  INREC IFOUTLEN=80,IFTHEN=(WHEN=INIT,       
  OVERLAY=(81:7,4,4,2,1,2,X,20,4,17,2,14,2, 
           25:81,8,Y4T,DATEDIFF,90,8,Y4T))   
//*


Bill,

Any specific reason for only 4 Bytes?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Mar 20, 2013 2:46 am
Reply with quote

It was the requirement :-)

I added the sign "for nothing".
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Mar 20, 2013 1:11 pm
Reply with quote

Thanks guys,

It's really good to get the methodology behind the solution.
Old dog still learning new tricks icon_wink.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts InfoSphere OPTIM CSV ouput vs DSNTIUA... IBM Tools 3
No new posts Timestamp difference and its average ... DB2 11
Search our Forums:

Back to Top