superhorse
Registered User.
- Local time
- Today, 11:10
- Joined
- Apr 14, 2008
- Messages
- 13
I have a column in a subform which displays the elapsed time in hours and minutes. I now want to be able to have a new column called cost, which multiplys the time by an hourly rate.
Would I be right in suggesting that I need to convert the hours and minutes into decimal format before I can do this calculation?
I used the following code to get the epapsed time column
Is there a similar process for a time to decimal conversion and how should I integrate the rates into the code.
That should keep you busy busy for a while
Would I be right in suggesting that I need to convert the hours and minutes into decimal format before I can do this calculation?
I used the following code to get the epapsed time column
Code:
Function GetElapsedTime(interval)
Dim totalhours As Long, totalminutes As Long, totalseconds As Long
Dim Hours As Long, Minutes As Long, Seconds As Long
totalhours = Int(CSng(interval * 24))
totalminutes = Int(CSng(interval * 1440))
totalseconds = Int(CSng(interval * 86400))
Hours = totalhours Mod 24
Minutes = totalminutes Mod 60
Seconds = totalseconds Mod 60
GetElapsedTime = Hours & " " & "Hours," & " " & Minutes & " " & "Minutes"
If Hours = 1 Then
GetElapsedTime = Hours & " " & "Hour," & " " & Minutes & " " & "Minutes"
End If
If Minutes = 0 And Hours = 1 Then
GetElapsedTime = Hours & " " & "Hour"
End If
If Minutes = 0 And Hours <> 1 Then
GetElapsedTime = Hours & " " & "Hours"
End If
If Hours = 0 Then
GetElapsedTime = Minutes & " " & "Minutes"
End If
End Function
Is there a similar process for a time to decimal conversion and how should I integrate the rates into the code.
That should keep you busy busy for a while
Last edited: