User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 427,227 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,216 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 Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 683 | Replies: 4
Reply
Join Date: Oct 2005
Posts: 3
Reputation: shashikanth is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
shashikanth shashikanth is offline Offline
Newbie Poster

Adding Time Values

  #1  
Jul 11th, 2008
I have a time values in MS Access database

4:30
2:15
3:20
4:45

I want to sum the time using VB code .The sum of the time should be 14:50 hrs not 14:10 hrs. Please help
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2008
Location: Sivakasi, Tamilnadu, India
Posts: 459
Reputation: selvaganapathy is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 79
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro in Training

Re: Adding Time Values

  #2  
Jul 11th, 2008
Hi, i think adding two time values are possible in VB6 just using time1 + time2.

Ex
  1. Dim Time1 As Date
  2. Dim Time2 As Date
  3. Dim TotalTime As Date
  4.  
  5. Time1 = "2:15"
  6. Time2 = "4:30"
  7.  
  8. TotalTime = Time1 + Time2
  9. Time1 = "3:20"
  10. Time2 = "4:45"
  11. TotalTime = TotalTime + Time1 + Time2
  12. MsgBox Hour(TotalTime) & " Hours " & Minute(TotalTime) & " Minutes" & Second(TotalTime) & " Seconds"
Last edited by selvaganapathy : Jul 11th, 2008 at 9:46 am.
KSG
Reply With Quote  
Join Date: Nov 2006
Posts: 712
Reputation: QVeen72 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 97
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Master Poster

Re: Adding Time Values

  #3  
Jul 11th, 2008
Hi,

You want to get Total in a Single Query..?
Is the Field in Access Table DateTime field or Single/Decimal field..?
You can do it in a single query...

Regards
Veena
Reply With Quote  
Join Date: Oct 2005
Posts: 3
Reputation: shashikanth is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
shashikanth shashikanth is offline Offline
Newbie Poster

Re: Adding Time Values

  #4  
Jul 12th, 2008
Originally Posted by QVeen72 View Post
Hi,

You want to get Total in a Single Query..?
Is the Field in Access Table DateTime field or Single/Decimal field..?
You can do it in a single query...

Regards
Veena


It is MS Access Date/time field. I tried using sum function but I did not get correct result.
Reply With Quote  
Join Date: Nov 2006
Posts: 712
Reputation: QVeen72 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 97
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Master Poster

Re: Adding Time Values

  #5  
Jul 12th, 2008
Hi,

Instead of simply using Sum, use this Query:

Select Sum(Val(MyDateTimeFld)) From MyTable

You will get total Time,
Later you need to get the Decimal Part, Integer Divide by 60, add it to Hours part, and keep the remainder in Decimal for Minutes..

Regards
Veena
Reply With Quote  
Reply

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

DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum

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