ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Convert two times to "Hours Worked" (https://www.excelbanter.com/excel-programming/304616-convert-two-times-hours-worked.html)

HotRod

Convert two times to "Hours Worked"
 
Is there an easy way to convert 8:35 AM to 4:30 PM into the total number of
hours worked? Without changing it into 8:35 and 16:30 and then splitting the
numbers apart and doing the math?



Norman Jones

Convert two times to "Hours Worked"
 
Hi HotRod,

Apologies -momentary abberation!

Should have been:

Sub Test10()

Dim TotalHours As Double
Dim start As Double, finish As Double
finish = #4:30:00 PM#
start = #9:30:00 AM#

TotalHours = (finish - start) * 24
MsgBox TotalHours
End Sub

---
Regards,
Norman


"Norman Jones" wrote in message
...
Hi HotRod,

Sub Test10()

Dim TotalHours As Double
Dim start As Double, finish As Double
finish = TimeValue("4:30PM")
start = TimeValue("9:30")

TotalHours = (finish - start) * 24
MsgBox TotalHours
End Sub


"HotRod" wrote in message
...
Is there an easy way to convert 8:35 AM to 4:30 PM into the total number

of
hours worked? Without changing it into 8:35 and 16:30 and then splitting

the
numbers apart and doing the math?







HotRod

Convert two times to "Hours Worked"
 
Ended up doing it the hard way by splitting it and then putting it back
together but I'll give this a try as well. THANKS



Norman Jones

Convert two times to "Hours Worked"
 
Hi HotRod,

Sub Test10()

Dim TotalHours As Double
Dim start As Double, finish As Double
finish = TimeValue("4:30PM")
start = TimeValue("9:30")

TotalHours = (finish - start) * 24
MsgBox TotalHours
End Sub


"HotRod" wrote in message
...
Is there an easy way to convert 8:35 AM to 4:30 PM into the total number

of
hours worked? Without changing it into 8:35 and 16:30 and then splitting

the
numbers apart and doing the math?






All times are GMT +1. The time now is 09:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com