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
 

 

Calculating date difference using DFSORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Calculating date difference using DFSORT
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Mon Jan 21, 2013 2:25 pm    Post subject: Reply to: Calculating date difference using DFSORT
Reply with quote

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

Moderator


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

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

Or Do you wanted to convert that into DFSORT?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Mon Jan 21, 2013 2:43 pm    Post subject: Reply to: Calculating date difference using DFSORT
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

Moderator


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

PostPosted: Mon Jan 21, 2013 3:21 pm    Post subject:
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    Post subject: Reply to: Calculating date difference using DFSORT
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    Post subject: Reply to: Calculating date difference using DFSORT
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: 1703
Location: Australia

PostPosted: Tue Jan 22, 2013 8:19 am    Post subject:
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    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 TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts How to get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am
No new posts Sticky: difference between ... DUMMY ... and ... enrico-sorichetti JCL & VSAM 0 Mon Oct 17, 2016 4:31 pm
This topic is locked: you cannot edit posts or make replies. Get correct date and time when curren... balaji81_k DB2 24 Fri Oct 14, 2016 10:40 pm


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