Hello everybody,

I have a function that returns HH:MM:SS from a number of seconds. I want the function to instead return HH:MM. I know I can just round up the minutes if seconds are more than zero, and then if the minutes become 00 I round up the hours. However I was wondering if there was a more elegant solution. Thank you.

Here is my HH:MM:SS function

Code:
Private Function TimeBetweenSeconds(TimeBegin As Variant, TimeEnd As Variant) As String

Dim intTimeOne As Double
Dim intTimeTwo As Double
Dim intDifference As Double

On Error GoTo ErrorHandler

intTimeOne = hour(TimeBegin) * 60 + minute(TimeBegin) + second(TimeBegin) / 60
intTimeTwo = hour(TimeEnd) * 60 + minute(TimeEnd) + second(TimeEnd) / 60

intDifference = intTimeTwo - intTimeOne

If intDifference < 0 Then
    intDifference = 1440 + intDifference
End If

TimeBetweenSeconds = Format$(CStr(Int(intDifference / 60)) & ":" & CStr(Int(((intDifference / 60) - Int(intDifference / 60)) * 60)) & ":" & round((intDifference - Int(intDifference)) * 60), "H:MM:SS")

Exit Function
ErrorHandler:
TimeBetweenSeconds = ""

End Function