DanielAttard
asked on
Convert elapsed time value into nearest 10th of an hour
I have a variable called ElapsedTime which represents the number of seconds between the StartTime and the current time.
Dim ElapsedTime As Long
ElapsedTime = Timer - StartTime
I want a function that convert this numer of seconds by rounding up to the nearest 10th of an hour, like this:
1-6 minutes = .1
6-12 minutes = .2
12-18 minutes = .3
18-24 minutes = .4
24-30 minutes = .5
30-36 minutes = .6
36-42 minutes = .7
42-48 minutes = .8
48-54 minutes = .9
54-60 minutes = 1.0
60-66 minutes = 1.1
etc.
What is the best way to accomplish this? Thank you.
Dim ElapsedTime As Long
ElapsedTime = Timer - StartTime
I want a function that convert this numer of seconds by rounding up to the nearest 10th of an hour, like this:
1-6 minutes = .1
6-12 minutes = .2
12-18 minutes = .3
18-24 minutes = .4
24-30 minutes = .5
30-36 minutes = .6
36-42 minutes = .7
42-48 minutes = .8
48-54 minutes = .9
54-60 minutes = 1.0
60-66 minutes = 1.1
etc.
What is the best way to accomplish this? Thank you.
Sorry, misread. Let me try again...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
that was quick and simple. thanks for the help.
Still not what you seem to want... Your text says "to the nearest" but your sample says otherwise.
Perhaps: round to the nearest minute and then round up to the nearest 10th?
( ( Round(ElapsedSeconds / 60) + 5 ) \ 6 ) / 10
Also, it should have been /3600 and not *3600 in my previous post, obviously ;)
(°v°)
Perhaps: round to the nearest minute and then round up to the nearest 10th?
( ( Round(ElapsedSeconds / 60) + 5 ) \ 6 ) / 10
Also, it should have been /3600 and not *3600 in my previous post, obviously ;)
(°v°)
You can use Round(dblElapsed, 1). BTW: if you declare ElapsedTime as Long, you will always get rounded seconds in your code. The conversion to long will be implicit in the assignation.
Timer returns a Single value.
Cheers!
(°v°)