Hi

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

00:00:00
(HoursMinutes,Seconds)


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)

Next

MsgBox(totalTime.Days & " days, " & totalTime.Hours & " hours, " & _
        totalTime.Minutes & " minutes and " & totalTime.Seconds & " seconds")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.