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
 

 

Time difference calculation

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Ramsee

New User


Joined: 06 Jan 2011
Posts: 52
Location: Chennai

PostPosted: Wed Dec 10, 2014 3:15 pm    Post subject: Time difference calculation
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: 1712
Location: UK

PostPosted: Wed Dec 10, 2014 3:37 pm    Post subject:
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: 52
Location: Chennai

PostPosted: Wed Dec 10, 2014 5:52 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Wed Dec 10, 2014 6:54 pm    Post subject: Reply to: Time difference calculation
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Dec 10, 2014 6:55 pm    Post subject: Reply to: Time difference calculation
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Dec 10, 2014 6:57 pm    Post subject: Reply to: Time difference calculation
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Dec 10, 2014 7:31 pm    Post subject: Re: Reply to: Time difference calculation
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: 1218
Location: Israel

PostPosted: Wed Dec 10, 2014 7:55 pm    Post subject: Re: Time difference calculation
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: 52
Location: Chennai

PostPosted: Thu Dec 11, 2014 11:54 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Get a job submitted itself every time... arunsoods JCL & VSAM 3 Tue Nov 22, 2016 4:05 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 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
No new posts cics & real time monitoring icehat CICS 5 Wed Sep 07, 2016 2:29 am


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