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

Facing problem in calculating Elapsed time


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

New User


Joined: 19 Mar 2008
Posts: 51
Location: Pune

PostPosted: Wed Jun 25, 2008 1:37 pm
Reply with quote

I'm facing one problem in calculating elapsed time .... I'm describing problem below

1) I've written one program which calculates the difference between file sent time and acknowledgement received time.

**file sent time is the time at which file is sent to ABC interface
**acknowledgement received time is the time at which we receive the acknowledgement from ABC interface.
NOTE:Time format is 24 hrs
**Elapsed time =acknowledgement received time - file sent time


program works fine if file sent time and acknowledgement received time are on same day. For example: say file sent time is 22:07:58(HH:MM:SS) and acknowledgement received time is 23:02:52(HH:MM:SS) then ELAPSED TIME is 00:54:54 (HH:MM:SS) which is correct.

program gives incorrect output if file sent time and acknowledgement received time are on different days.
Foe EXAMPLE: If file sent time is 23:08:47 and acknowledgement received time is 00:14:21(Next day) elapsed time calculated by program is 22:54:26 which is wrong......

Can anybody suggest me how to tackle this problem
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jun 25, 2008 2:03 pm
Reply with quote

take the day into account when calculating elapsed time.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jun 25, 2008 2:04 pm
Reply with quote

Quote:
elapsed time calculated by program is 22:54:26 which is wrong......


is wrong because the algorithm or the implementation is wrong icon_cool.gif

here is the pseudocoding for the right approach
Code:
temp = end - start

if temp >  0 then ,
    elapsed = temp
else ,
    elapsed = temp + 24  hrs
Back to top
View user's profile Send private message
Rajesh Sampath

New User


Joined: 18 Jun 2008
Posts: 9
Location: Pune

PostPosted: Wed Jun 25, 2008 3:16 pm
Reply with quote

Hi enrico-sorichetti

Ya its working fine. But its calculate within the 24 hours.

Im saying,

File sending time is 24/06/2008 at 23:08:47 and acknowledgement received time is 00:14:21 on 26/06/2008.

In this case.

We calculate the date also.. icon_idea.gif

Please correct me. If im wrong

Rajesh Sampath
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jun 25, 2008 3:51 pm
Reply with quote

You are not wrong...
If You had said that You had a full timestamp,
I would not have lost time posting an incomplete solution...


use the integer of date to transform the data into an absolute number of days ...

reduce everything to seconds...

time = days*24*60*60 + hours*60*60 + minutes*60 + seconds

elapsed = end - start

use modulus arithmetic to find out the ..
elapsed... days hours minutes seconds

but usually an elapsed is measured in hours minutes seconds ( no days )
Back to top
View user's profile Send private message
bijal.awhad

New User


Joined: 19 Mar 2008
Posts: 51
Location: Pune

PostPosted: Mon Jun 30, 2008 2:17 pm
Reply with quote

Thanks to all who helped me..

Thanks enrico sorichetti

This is really a helpful forum

Regards
Bijal icon_razz.gif
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 Map Vols and Problem Dataset All Other Mainframe Topics 2
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
Search our Forums:

Back to Top