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

Need to calculate the number of days between two dates


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

New User


Joined: 07 Jun 2007
Posts: 31
Location: Spain

PostPosted: Mon May 26, 2008 2:14 pm
Reply with quote

Input:
Code:

20080520 20080526
20080525 20080526


Output:
Code:

20080520 20080526 00006
20080525 20080526 00001


I need to calculate the number of days between two dates....
Back to top
View user's profile Send private message
bbharathiraj
Warnings : 1

New User


Joined: 26 Oct 2006
Posts: 50
Location: Chennai

PostPosted: Mon May 26, 2008 7:41 pm
Reply with quote

I also tried to achieve like this same. If some one help me to get the output for the following

I have a date on my input file which is record created date in table.

For example,

Code:
20080520 rajak 
20080525 frank


I have to calculate the number of days with the current system date. And if the number of days fall in 0-5 days then I have to write as A in the same file at the last column.
If the number of days fall in 6-10 days then I have to write as B in the same file at the last column.

So the output should be like as below if the system date is 05/26/2008.

Code:
20080520 rajak B
20080525 frank A


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

Senior Member


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

PostPosted: Tue May 27, 2008 10:39 pm
Reply with quote

The following DFSORT JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=ICEMAN                                   
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD *                                             
20080520 RAJAK                                               
20080525 FRANK                                               
//SORTOUT  DD SYSOUT=*                                       
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                           
  OUTREC IFOUTLEN=80,                                       
         IFTHEN=(WHEN=INIT,OVERLAY=(81:DATE1-5)),           
         IFTHEN=(WHEN=(1,8,CH,LT,81,8,CH),OVERLAY=(16:C'B')),
         IFTHEN=(WHEN=NONE,OVERLAY=(16:C'A'))               
/*


Hope this helps...
Back to top
View user's profile Send private message
V S Amarendra Reddy

Active User


Joined: 13 Sep 2006
Posts: 216
Location: USA

PostPosted: Thu May 29, 2008 7:50 am
Reply with quote

Skolusu,

Can you please give the solution for gabriel's post also. I just want to know how to get the difference of dates. Is it possible in DFSORT to get the days between dates...

Regards
Amar
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu May 29, 2008 8:06 am
Reply with quote

Hello Amar,

Please check this prior topic:
http://ibmmainframes.com/viewtopic.php?t=29164
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:15 am
Reply with quote

gabriel.ryoga/V S Amarendra Reddy,


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----+-
20080520 20080526                             
20080525 20080526                             
//SORTOUT  DD SYSOUT=*                       
//SYSIN    DD *                               
  SORT FIELDS=COPY                           
  INREC OVERLAY=(20:10,8,Y4T,DATEDIFF,1,8,Y4T)
//*


The output from the above job is

Code:

20080520 20080526  +0000006   
20080525 20080526  +0000001   



For complete details of date arithmetic functions and other new functions see "User Guide for DFSORT PTFs UK90025 and UK90026" paper (sortugph.pdf) at:

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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts To fetch records that has Ttamp value... DFSORT/ICETOOL 4
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Increase the number of columns in the... IBM Tools 3
Search our Forums:

Back to Top