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

Calculating date difference using DFSORT


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

New User


Joined: 10 Dec 2012
Posts: 20
Location: Australia

PostPosted: Mon Jan 21, 2013 2:19 pm
Reply with quote

Hi,

I have two files with the date format as mentioned below.

File 1
DD/MM/YY

File 2
DD/MM/YY

I need to calculate the difference between the two dates and create a output record in the following layout. Could some one guide me pls.

$$DD01 COPY REPL=(55,EQ,C'DAY( )',C'DAY(XXXXX)')

In the above record, XXXXX represents the number of days difference computed above.

Thanks
Bharath
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: Mon Jan 21, 2013 2:25 pm
Reply with quote

That's not DFSORT code.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Mon Jan 21, 2013 2:35 pm
Reply with quote

Or Do you wanted to convert that into DFSORT?
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: Mon Jan 21, 2013 2:43 pm
Reply with quote

Thanks Pandora-box. It is the "expected output", not the command to achieve something :-)
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Mon Jan 21, 2013 3:21 pm
Reply with quote

Hi Does both the files have one record or more than 1?

Anytime Bill ... I did read it wrong the first time icon_smile.gif
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Jan 22, 2013 12:22 am
Reply with quote

Bharath RajaramSridharan,

Use the following DFSORT JCL which will give you the desired results
Code:

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//INA      DD *                                                   
21/01/13                                                         
//INB      DD *                                                   
21/01/12                                                         
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                   
  OPTION COPY,Y2PAST=1980                                         
  JOINKEYS F1=INA,FIELDS=(8,1,A),SORTED,NOSEQCK                   
  JOINKEYS F2=INB,FIELDS=(8,1,A),SORTED,NOSEQCK                   
  REFORMAT FIELDS=(F1:1,8,F2:1,8)                                 
  INREC BUILD=(C'$$DD01 COPY REPL=(55,EQ,C''',C'DAY( )''',C',C''',
               C'DAY(',1,6,Y2T,DATEDIFF,9,6,Y2T,C')''',C')',80:X)
//*                                                               
//JNF1CNTL DD *                                                   
  OPTION STOPAFT=1                                               
  INREC BUILD=(7,2,4,2,1,2,2X)                                   
//*                                                               
//JNF2CNTL DD *                                                   
  OPTION STOPAFT=1                                               
  INREC BUILD=(7,2,4,2,1,2,2X)                                   
//*


The output from this is
Code:

$$DD01 COPY REPL=(55,EQ,C'DAY( )',C'DAY(+0000366)')
Back to top
View user's profile Send private message
Bharath RajaramSridharan

New User


Joined: 10 Dec 2012
Posts: 20
Location: Australia

PostPosted: Tue Jan 22, 2013 8:00 am
Reply with quote

Thanks Skolusu for helping me with the solution.

As I stated in my post, my requirement was to create the following card which would be used in a fileaid step after the sort, the XXXXX value can hold only 5 Chars.

$$DD01 COPY REPL=(55,EQ,C'DAY( )',C'DAY(XXXXX)')

So after executing the sort card you have provided, I wrote another sort card to remove the sign bit and the leading two zeroes which the DATEDIFF command would return.

Code:
//STEP0100 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD *                                       
$$DD01 COPY REPL=(55,EQ,C'DAY(     )',C'DAY(+0000366)')
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                       
  SORT FIELDS=COPY                                     
  INREC BUILD=(1,44,48,8,28X)                         
/*


The above job step would give me a reformatted card like the one below mentioned

$$DD01 COPY REPL=(55,EQ,C'DAY( )',C'DAY(00366)')

Is there a way to incorporate the same functionality (To use only the last 5 bytes of the DATEDIFF) in the original sysin card itself which you have provided.

Thanks
Bharath
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Tue Jan 22, 2013 8:19 am
Reply with quote

Hi,

here is one way

Code:
  OPTION COPY,Y2PAST=1980                                         
  JOINKEYS F1=INA,FIELDS=(8,1,A),SORTED,NOSEQCK                   
  JOINKEYS F2=INB,FIELDS=(8,1,A),SORTED,NOSEQCK                   
  REFORMAT FIELDS=(F1:1,8,F2:1,8)                                 
  INREC BUILD=(1,6,Y2T,DATEDIFF,9,6,Y2T)                           
  OUTREC BUILD=(C'$$DD01 COPY REPL=(55,EQ,C''',C'DAY( )''',C',C''',
               C'DAY(',4,5,C')''',C')',80:X)                       



Gerry
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 Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts DFsort help with SUM() DFSORT/ICETOOL 12
Search our Forums:

Back to Top