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

Time difference calculation


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Ramsee

New User


Joined: 06 Jan 2011
Posts: 53
Location: Chennai

PostPosted: Wed Dec 10, 2014 3:15 pm
Reply with quote

Hi All,

Warm greetings!!

I need a help to find the time difference between the two timestamp.

INPUT:
Code:

START TIME     END TIME
05:10:00          07:20:00
05:15:00          05:30:00
06:59:00          07:10:00
05:50:00          06:55:00


OUTPUT:
START TIME    END TIME     TOTAL TIME
05:10:00        07:20:00       02:10:00
05:15:00        05:30:00       00:15:00
06:59:00        07:10:00       00:11:00
05:50:00        06:55:00       01:05:00
23:15:00        01:00:00       00:45:00


I tried a lot using CEESECS/CEEDATM for time difference calucation but not able get result as my compiler says.
Code:

* Statistics for COBOL program CBLSECS:                     
*    Source records = 98                                     
*    Data Division statements = 25                           
*    Procedure Division statements = 19                     
End of compilation 1,  program CBLSECS,  highest severity 12.
Return code 12                                               


Please guide me to solve this issue.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Wed Dec 10, 2014 3:37 pm
Reply with quote

How about showing the code? For all we know the 12 is nothing to do with your coding of the 2 functions that you mention.

Are you catering for events running past midnight, eg start 23:30 end 00:15? All your examples show start time less than end time.
Back to top
View user's profile Send private message
Ramsee

New User


Joined: 06 Jan 2011
Posts: 53
Location: Chennai

PostPosted: Wed Dec 10, 2014 5:52 pm
Reply with quote

Hi Nic,

we run the jobs past midnight as well,

Code:

START TIME    END TIME     TOTAL TIME
23:15:00        01:00:00       00:45:00
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Dec 10, 2014 6:54 pm
Reply with quote

Code:
START TIME    END TIME     TOTAL TIME
23:15:00        01:00:00       00:45:00

icon_eek.gif

why not review Your way of doing things
meditate a bit ... meditate
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: Wed Dec 10, 2014 6:55 pm
Reply with quote

Still not shown the code, so no way at all to guess what is wrong, other than guessing, which is pretty pointless.

Without the date as well, if you have a job running from 23:59 to 00:01 the day after the following day, you'll report two minutes instead of 24 hours and two minutes. So look out if you have things in your list which execute for more than 24 hours :-)
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Dec 10, 2014 6:57 pm
Reply with quote

Review the LE (Language Environment) Callable Service routine "CEESECS", which converts a given Date/Timestamp to Lilian Seconds. If you call it twice, with the starting and ending Date/Timestamp, subtract the starting Lilian result from the ending Lilian result and you'll have the difference in seconds. You can then convert these seconds to your desired "Time" format manually or use "CEEDATM". This method doesn't care if you started just before Midnight and ended after Midnight.

Search the MAINFRAME COBOL forum for CEESECS. You'll get many hits....

HTH....
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: Wed Dec 10, 2014 7:31 pm
Reply with quote

enrico-sorichetti wrote:
Code:
START TIME    END TIME     TOTAL TIME
23:15:00        01:00:00       00:45:00

icon_eek.gif

why not review Your way of doing things
meditate a bit ... meditate


It's a special end-of-day time discount, :-)

Ramsee, that particular example in your output doesn't appear in your input. So you missed it. not Nic.

Have a look at your compile options in the compiler listing. Do you have NOFLAG or FLAG(U)?
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Wed Dec 10, 2014 7:55 pm
Reply with quote

Ramsee wrote:
I tried a lot using CEESECS/CEEDATM for time difference calucation but not able get result as my compiler says.
Code:

* Statistics for COBOL program CBLSECS:                     
*    Source records = 98                                     
*    Data Division statements = 25                           
*    Procedure Division statements = 19                     
End of compilation 1,  program CBLSECS,  highest severity 12.
Return code 12                                               
You have compilation errors, that's all.
There are error messages right above these lines. What are they ?

For time arithmetics, you don't really need to use LE services:
If END time is on next day, add 24 to HOURS,
Compute the number of seconds: (((HOURS * 60) + MINS) * 60) + SECS for both END and START times,
Subtract the 2 numbers,
Recalculate the duration from seconds into time.

For example: 23:15:00 gives 83700 seconds,
01:00:00 (on next day so 25:00:00) gives 90000
The difference is 90000 - 83700 = 6300 seconds
Divide once by 60, gives 105 minutes with a remainder of 00 seconds.
Divide once more by 60, gives 1 hour with a remainder of 45 minutes.

So 01:00:00 - 23:15:00 gives 01:45:00 (and not 00:45:00)
Back to top
View user's profile Send private message
Ramsee

New User


Joined: 06 Jan 2011
Posts: 53
Location: Chennai

PostPosted: Thu Dec 11, 2014 11:54 am
Reply with quote

Hi All,

I am sorry for the late reply and not giving a full information on the topic.

The compiler issue was due to some parameter setup(In house) in my Compile JCL which is rectified now, and i am able to use the CEESECS/CEEDATM to calculate the time difference.

I thanks Mr.NIC ,Mr. Enrico, Mr.Bill O'Boyle,Mr. Bill Woodger,Mr.Marso and everyone for your time and help.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts To get the the current time DFSORT/ICETOOL 13
No new posts RC query -Time column CA Products 3
No new posts C Compile time time stamps Java & MQSeries 10
No new posts Parallelization in CICS to reduce res... CICS 4
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
Search our Forums:

Back to Top