0

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?

2
Contributors
1
Reply
5
Views
9 Years
Discussion Span
Last Post by Fungus1487
0

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")
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.