User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 363,385 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,825 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser:
Views: 413 | Replies: 1
Reply
Join Date: Apr 2008
Posts: 32
Reputation: ninjaimp is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
ninjaimp ninjaimp is offline Offline
Light Poster

adding time duration together

  #1  
May 12th, 2008
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?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2007
Location: Birmingham
Posts: 366
Reputation: Fungus1487 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 34
Fungus1487's Avatar
Fungus1487 Fungus1487 is offline Offline
Posting Whiz

Re: adding time duration together

  #2  
May 13th, 2008
Do you have this data in date variables or as strings ?

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

  1. Dim totalTime As New TimeSpan(0, 0, 0) ' Declare a timespan outside the loop to hold the count
  2.  
  3. For Each Record ' Create your loop to iteratively work through the returned results
  4.  
  5. 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
  6. Dim timTmp As TimeSpan = new TimeSpan(cint(arrStr(0)), _
  7. cint(arrStr(1)), cint(arrStr(2)))
  8. totalTime = totalTime.Add(timTmp)
  9.  
  10. Next
  11.  
  12. MsgBox(totalTime.Days & " days, " & totalTime.Hours & " hours, " & _
  13. totalTime.Minutes & " minutes and " & totalTime.Seconds & " seconds")
When Autumn Falls [ http://www.whenautumnfalls.co.uk ] &&
Designdotworks [ http://www.designdotworks.co.uk ] Web / Graphic / Software Design
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb VB.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the VB.NET Forum

All times are GMT -4. The time now is 12:23 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC