Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
Select Sum([Time to Abandon]) From Table1
Open in new window
Select FormatHourMinuteSecond(Sum([Time to Abandon])) From Table1
Public Function FormatHourMinuteSecond( _
ByVal datTime As Date, _
Optional ByVal strSeparator As String = ":") _
' Returns count of days, hours, minutes, and seconds of datTime
' converted to hours, minutes, and seconds as a formatted string
' with an optional choice of time separator.
' datTime: #10:03:55# + #20:01:24#
' returns: 30:05:19
' 2014-06-17. Cactus Data ApS, CPH.
Dim strHour As String
Dim strMinuteSec As String
Dim strHours As String
strHour = CStr(Fix(datTime) * 24 + Hour(datTime))
' Add leading zero to minute and second count when needed.
strMinuteSec = Right("0" & CStr(Minute(datTime)), 2) & strSeparator & Right("0" & CStr(Second(datTime)), 2)
strHours = strHour & strSeparator & strMinuteSec
FormatHourMinuteSecond = strHours
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.