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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with dividing by time

Status
Not open for further replies.

LongFeiFengWu

Technical User
Nov 9, 2001
98
US
I need some help with dividing by time. What I have is as follows:

Value A: 31027 (Contacts)
Value B: 4507:17:03 (4507 hours, 17 minutes, 3 seconds)

I need to take Value B and format it in hours, so that it reads (example) 4507.25 hours. Then I need to divide the contacts by the hours to get the item I'm looking for.

Any help is appreciated.

"If nothing within you stays rigid, outward things will disclose themselves. Moving, be like water. Still, be like a mirror. Respond like an echo." ~ Bruce Lee
 
How about something like:

Dim timearr, timestring, numcontacts, minutes, hours, result

numcontacts = 31027
timestring = "4507:17:03"

timearr = Split(timestring, ":")
hours = timearr(0) * 1
minutes = timearr(1) * 1

If minutes < 8 Then
hours = hours + .0 'or simply comment this whole line out
ElseIf minutes < 23 Then
hours = hours + .25
ElseIf minutes < 38 Then
hours = hours + .5
ElseIf minutes < 53 Then
hours = hours + .75
Else
hours = hours + 1
End If

result = contacts / hours

Lee
 
Or this... to eliminate the rounding

numcontacts = 31027
timestring = "4507:17:03"

timearr = Split(timestring, ":")
ContactsPerHour = numcontacts / (arTime(0) + arTime(1) / 60 + arTime(2) / 3600)

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top