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
 

 

Facing problem in calculating Elapsed time

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Facing problem in calculating Elapsed time
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: 6967
Location: porcelain throne

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

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

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Wed Jun 25, 2008 2:04 pm    Post subject: Reply to: [b]Facing problem in calculating Elapsed time Plea
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Wed Jun 25, 2008 3:51 pm    Post subject: Reply to: Facing problem in calculating Elapsed time
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    Post subject:
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    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
No new posts DSNACCOX (can it be run on 1 db/ts, t... SRICOBSAS DB2 3 Sat May 06, 2017 12:59 am
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm
No new posts Application not run by time HH:MM tri... jzhardy IBM Tools 1 Sun Apr 09, 2017 3:22 pm
No new posts Strings with double quotes having pro... raja Arumugam All Other Mainframe Topics 11 Thu Mar 30, 2017 10:34 am
No new posts Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm


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