Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting seconds into Average Minutes

Status
Not open for further replies.

jabedin

Programmer
Feb 24, 2004
37
0
0
AU
Hi There,

I have calculated second from two datetime value. I need to present the average time by minutes and time format. I used following statement to transfer the value into time and minutes.

=Floor((<Activation Time - TimeInSec(Act-Day)>/<Activation - Cases(Act-Day)>)/60)+ (Mod((<Activation Time - TimeInSec(Act-Day)>/<Activation - Cases(Act-Day)>) ,60)/100)

This is working fine until I have got a time 01:595(MM:SS). As this is actually a decimal format, it roundup to 01:60 which I do not want. Is there anyway, I can stop roundup or would there be any other easy way I am miising.

I will highly appreciate your help regarding this.

Regards
Jay

 
I think if you subtract .5 seconds from your number everytime, it will round up naturally to exactly what you want.

Steve Krandel
Symantec
 
Hi Steve,

Thanks for the quick reply.

Now, taking .5 seconds deduction may not work properly.
Two example of calculated time could be
01.59532(mm.ss) , 01.50532(mm.ss). If I deduct unconditional .5 would give me incorrect result. I need to deduct only when mm.ss is 01.595 or above.

Any would have some suggestion will be highly appreciated.
 
I disagree. In both your examples, it would work fine.

1.59532-.005 = 1.59032 which rounds to 1.59

1.50532-.005 = 1.50032 which rounds to 1.50

That's what you want. I thought you wanted to trucate off the anything below 1 second. I don't see why this doesn't work.



Steve Krandel
Symantec
 
Hi Steve,

Thank you very much. I think this will work. I was wondering how this will work when the time is 1.59032. If I deduct .005 it will be 1.58532 which will round up to 1.59. I missed the round up in the first place.

Thanks for the big help.

Regards
Jay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top