Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Difference between dates in European format

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

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Mar 19, 2013 8:27 pm    Post subject: Difference between dates in European format
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

Active Member


Joined: 08 May 2006
Posts: 998
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Tue Mar 19, 2013 9:14 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Tue Mar 19, 2013 9:34 pm    Post subject: Reply to: Difference between dates in European format
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    Post subject: Reply to: Difference between dates in European format
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Mar 20, 2013 2:46 am    Post subject: Reply to: Difference between dates in European format
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: 8593
Location: Back in jolly old England

PostPosted: Wed Mar 20, 2013 1:11 pm    Post subject:
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    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 in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 5 Fri Sep 22, 2017 4:56 pm
No new posts Fetch Previous month & year in MM... girishb2 DFSORT/ICETOOL 3 Thu Sep 21, 2017 9:54 pm
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts FTP data transfer from PC to Mainfram... AJAYREDDY All Other Mainframe Topics 8 Wed Aug 23, 2017 9:59 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us