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 

Date/Time Calculation

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
MikeMara
Beginner


Joined: 09 Oct 2006
Posts: 6
Topics: 2
Location: Tampa, Florida

PostPosted: Mon Oct 09, 2006 6:59 pm    Post subject: Date/Time Calculation Reply with quote

Can anyone provide me with a Rexx code to display the number of hours||minutes||seconds from 2 dates and times?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Oct 10, 2006 9:54 am    Post subject: Reply with quote

MikeMara,

Check this link

http://listserv.uark.edu/scripts/wa.exe?A2=ind0110&L=ibmvm&T=0&P=21545

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
MikeMara
Beginner


Joined: 09 Oct 2006
Posts: 6
Topics: 2
Location: Tampa, Florida

PostPosted: Tue Oct 10, 2006 11:20 am    Post subject: Reply with quote

Actually, I saw this website, but it executes more than what I available on the mainframe. I tried coding the pieces I could use, but it was not enough.
Back to top
View user's profile Send private message
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Thu Oct 12, 2006 2:10 pm    Post subject: Reply with quote

I'm still developing this bit of code, I have some issues with rounding, but maybe it'll help you get started:

Code:

/* REXX DATEDIFF */                                                     
Numeric Digits 13                                                       
fromdate = '01/01/06'                                                   
fromtime = '00:00:00'                                                   
todate   = '10/12/06'                                                   
totime   = '15:03:00'                                                   
fromdate_b = Date(B,fromdate,U)                                         
todate_b   = Date(B,todate,U)                                           
Say 'DATEDIFF' fromdate fromdate_b fromtime '-' todate todate_b totime 
ndays = todate_b - fromdate_b                                           
fulldays = 0                                                           
If ndays > 1 Then fulldays = (ndays - 1) * 86400                       
Parse Var fromtime hh ':' mm ':' ss .                                   
fromtime_e = (hh * 3600) + (mm * 60) + ss                               
fromtime_ss = 86400 - fromtime_e                                       
Parse Var totime hh ':' mm ':' ss .                                     
totime_ss = (hh * 3600) + (mm * 60) + ss                               
total_ss = fromtime_ss + fulldays + totime_ss                           
                                                                       
                                                                     
If total_ss >= 86400 Then                                             
  Do                                                                 
    days = (total_ss % 86400)                                         
  End                                                                 
Else days = 0                                                         
If total_ss - (days * 86400) >= 3600 Then                             
  Do                                                                 
    hours = ((total_ss - (days * 86400)) % 3600)                     
  End                                                                 
Else hours = 0                                                       
If total_ss - (hours * 3600) - (days * 86400) >= 60 Then             
  Do                                                                 
    minutes = ((total_ss - (hours * 3600) - (days * 86400)) % 60)     
  End                                                                 
Else minutes = 0                                                     
seconds = total_ss - (minutes * 60) - (hours * 3600) - (days * 86400)
                                                                     
                                                       
Say Right('Days',4)' 'Right('Hours',5)||,             
  ' 'Right('Minutes',7)' 'Right('Seconds',7)           
Say Right(days,4,'0')' 'Right(hours,5,'0')||,         
  ' 'Right(minutes,7,'0')' 'Right(seconds,7,'0')       
                                                       
Back to top
View user's profile Send private message
MikeMara
Beginner


Joined: 09 Oct 2006
Posts: 6
Topics: 2
Location: Tampa, Florida

PostPosted: Fri Oct 13, 2006 6:32 am    Post subject: Reply with quote

Thank-you very much for the sample! I tried it and so far the results seem to be accurate.
Back to top
View user's profile Send private message
MikeMara
Beginner


Joined: 09 Oct 2006
Posts: 6
Topics: 2
Location: Tampa, Florida

PostPosted: Thu Oct 19, 2006 10:19 am    Post subject: Reply with quote

I tried different scenarios with your code and found 1 issue. Days = 1 with the following dates/times. It should equal 0.

Fromdate = 10/19/2006
Fromtime = 11:08:00
ToDate = 10/19/2006
ToTime = 11:18:00
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF 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