KirkJewell
Programmer
I have a StartTime and EndTime and I need to know the difference in hours (preferable 6 1/2 hours as 6.5
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Function basDbl2HrsMin(AccumTime As Double) As String
Dim tmpDays As Double
Dim tmpHrs As Double
Dim tmpMins As Double
Dim tmpTime As Double
Dim tmpStr As String
tmpDays = Int(AccumTime)
tmpTime = (AccumTime - tmpDays) * 1440 'Fraction to Mins
tmpMins = tmpTime Mod 60
tmpTime = tmpTime - Int(tmpMins)
tmpHrs = tmpTime \ 60
'formatting for Day(s)
If (tmpDays) Then
tmpStr = tmpDays & "Day"
If (tmpDays > 1) Then
tmpStr = tmpStr & "s"
End If
End If
'formatting for Hour(s)
If (tmpHrs) Then
tmpStr = tmpStr & " " & tmpHrs & "Hr"
If (tmpHrs > 1) Then
tmpStr = tmpStr & "s"
End If
End If
'formatting for Minutes(s)
If (tmpMins) Then
tmpStr = tmpStr & " " & tmpMins & "Min"
If (tmpMins > 1) Then
tmpStr = tmpStr & "s"
End If
End If
basDbl2HrsMin = tmpStr
End Function
[code] MichaelRed
m.red@att.net
There is never time to do it right but there is always time to do it over
Public Function basDbl2HrsMin(AccumTime As Double) As String
Dim tmpDays As Double
Dim tmpHrs As Double
Dim tmpMins As Double
Dim tmpTime As Double
Dim tmpStr As String
Dim SignOfTheTimes As Integer
SignOfTheTimes = Sgn(AccumTime)
tmpDays = Int(Abs(AccumTime))
tmpTime = Abs((AccumTime - tmpDays)) * 1440 'Fraction to Mins
tmpMins = tmpTime Mod 60
tmpTime = tmpTime - Int(tmpMins)
tmpHrs = tmpTime \ 60
'formatting for Day(s)
If (tmpDays) Then
tmpStr = tmpDays & "Day"
If (tmpDays > 1) Then
tmpStr = tmpStr & "s"
End If
End If
'formatting for Hour(s)
If (tmpHrs) Then
tmpStr = tmpStr & " " & tmpHrs & "Hr"
If (tmpHrs > 1) Then
tmpStr = tmpStr & "s"
End If
End If
'formatting for Minutes(s)
If (tmpMins) Then
tmpStr = tmpStr & " " & tmpMins & "Min"
If (tmpMins > 1) Then
tmpStr = tmpStr & "s"
End If
End If
'Accounting for the possibility of negative time
If (SignOfTheTimes <> 0) Then
tmpStr = "Minus " & tmpStr
End If
basDbl2HrsMin = tmpStr
End Function