I have a small program that imports data and part of this data is in duration format:


What im trying to do is add these together so that they show a cumalative duration, but im not at all sure how?

Do you have this data in date variables or as strings ?

ill presume its a string if it isnt skip the first part.

Dim totalTime As New TimeSpan(0, 0, 0) ' Declare a timespan outside the loop to hold the count

For Each Record ' Create your loop to iteratively work through the returned results

    Dim arrStr As String() = yourVariable.split(cchar(":")) ' Break apart your string if you already have it in DateTime object then simply change the method below to use the "Hours", "Minutes" and "Seconds" property of the object
    Dim timTmp As TimeSpan = new TimeSpan(cint(arrStr(0)), _
            cint(arrStr(1)), cint(arrStr(2)))
    totalTime = totalTime.Add(timTmp)


MsgBox(totalTime.Days & " days, " & totalTime.Hours & " hours, " & _
        totalTime.Minutes & " minutes and " & totalTime.Seconds & " seconds")