MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Adding times using Dfsort/Icetool

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
chirag2901
Beginner


Joined: 19 Apr 2006
Posts: 7
Topics: 4

PostPosted: Sun Apr 23, 2006 8:53 pm    Post subject: Adding times using Dfsort/Icetool Reply with quote

Hi guys,

I have an input file with two columns. Both are times. Format is as below:

Code:
00:01:00 14:00:00
00:02:00 07:00:00
00:01:00 20:30:00


I want to add a third column, which is the addition of first and second column.

e.g. Output:

Code:
00:01:00 14:00:00 14:01:00
00:02:00 07:00:00 07:02:00
00:01:00 20:30:00 20:31:00


Any way to do this using dfsort / icetool ?

Thanks,
Chirag
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Mon Apr 24, 2006 5:01 am    Post subject: Reply with quote

chirag2901,

Adding 2 times is easy but you need to define the rules. what happens if the sum of 2 times is greater than 24 hours? do you want the sum as 1 day 10 hours and 35 minutes and 22 seconds or 34 hours 35 minutes and 22 seconds.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
chirag2901
Beginner


Joined: 19 Apr 2006
Posts: 7
Topics: 4

PostPosted: Mon Apr 24, 2006 5:32 am    Post subject: Reply with quote

Hi Kolusu, tx. for your reply.

I think I will go with the second option. 34 hours, 25 min. , 20 seconds.

thanks,
chirag
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Mon Apr 24, 2006 8:13 am    Post subject: Reply with quote

chirag2901,

The following DFSORT JCL will give you the desired results. We first convert the both times into seconds and then add up and finally arrive at a number with total seconds. From that we derive the time back using the following calculation.

Code:

time in seconds = nnnnnnn

days = time / 86400
hours = (time / 3600) - (days * 24)
minutes = (time / 60) - (days * 1440) - (hours * 60)
seconds = time mod 60


Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT DD SYSOUT=*                                     
//SORTIN DD *                                           
00:01:00 14:00:00                                       
00:02:00 07:00:00                                       
00:01:32 20:30:00                                       
13:41:52 15:30:59                                       
//SORTOUT DD SYSOUT=*                                   
//SYSIN DD *                                             
  SORT FIELDS=COPY                                       
  INREC OVERLAY=(20:+3600,MUL,01,02,ZD,ADD,             
                    +0060,MUL,04,02,ZD,ADD,             
                    07,2,ZD,ADD,                         
                    +3600,MUL,10,02,ZD,ADD,             
                    +0060,MUL,13,02,ZD,ADD,             
                    16,2,ZD,M11,LENGTH=8,X,             
                    20,08,ZD,DIV,+86400,M11,LENGTH=8,X, 
                   (20,08,ZD,DIV,+3600),M11,LENGTH=8,X, 
                   (20,08,ZD,DIV,+60),SUB,               
                   (29,8,ZD,MUL,+1440),SUB,             
                   (38,8,ZD,MUL,+60),M11,LENGTH=8,X,     
                   20,8,ZD,MOD,+60,M11,LENGTH=8)         
                                                         
  OUTREC BUILD=(01:01,19,                               
                20:38,8,ZD,M11,LENGTH=2,                 
                22:C':',                                 
                23:47,8,ZD,M11,LENGTH=2,                 
                25:C':',                                 
                26:56,8,ZD,M11,LENGTH=2)                 
                                                         
/*                                                       


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
advoss
Beginner


Joined: 23 Aug 2005
Posts: 26
Topics: 0

PostPosted: Mon Apr 24, 2006 11:33 am    Post subject: Reply with quote

I think something is wrong...

The answer for the fourth one should be 29:12:51, but Kolusu's script gives an answer of 29:28:51.
_________________
Alan Voss
Back to top
View user's profile Send private message
advoss
Beginner


Joined: 23 Aug 2005
Posts: 26
Topics: 0

PostPosted: Mon Apr 24, 2006 12:00 pm    Post subject: Reply with quote

Update to my last note.
I believe that line 10 of the INREC statement should be:
(29,8,ZD,MUL,+60),SUB,
_________________
Alan Voss
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Mon Apr 24, 2006 12:48 pm    Post subject: Reply with quote

advoss,

advoss,

Thanks for correcting me. I made a mistake while caluculating the time.

Here are the modified control cards.

Code:

//SYSIN DD *                                                   
  SORT FIELDS=COPY                                             
  INREC OVERLAY=(20:+3600,MUL,01,02,ZD,ADD,                   
                    +0060,MUL,04,02,ZD,ADD,                   
                    07,2,ZD,ADD,                               
                    +3600,MUL,10,02,ZD,ADD,                   
                    +0060,MUL,13,02,ZD,ADD,                   
                    16,2,ZD,M11,LENGTH=8,X,                   
                   (20,08,ZD,DIV,+3600),M11,LENGTH=8,X,       
                   (20,08,ZD,MOD,+3600),DIV,+60,M11,LENGTH=8,X,
                   20,8,ZD,MOD,+60,M11,LENGTH=8)               
                                                               
  OUTREC BUILD=(1,19,                                         
                20:29,8,ZD,M11,LENGTH=2,                       
                22:C':',                                       
                23:38,8,ZD,M11,LENGTH=2,                       
                25:C':',                                       
                26:47,8,ZD,M11,LENGTH=2)                       
/*                                                             


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
boddapati_siva
Beginner


Joined: 25 Apr 2006
Posts: 1
Topics: 0

PostPosted: Sat Apr 29, 2006 4:19 am    Post subject: Reply with quote

can u explain the code furthur
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Sat Apr 29, 2006 11:25 am    Post subject: Reply with quote

boddapati_siva,

I am not sure what you mean by explain more. it is quite simple.

First convert the time into seconds

Code:

HH:MM:SS = (3600 * HH) + (60 * MM) + SS = TOTAL SECS


Perform the same formula for the second time also.

Code:

Grand total of secs = ( Total secs 1 + total secs 2)


Now to get the time back in HH:MM:SS use the following formula
Code:

HH  = GRAND TOTAL SECS/ 3600

MM  = (REMAINDER OF GRAND TOTAL SECS /3600) / 60

SS  = (REMAINDER OF GRAND TOTAL SECS/60)


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group