Solved

addition of hours and also minutes in gridview i.e subtotal and grand total.

Posted on 2008-09-30
4
692 Views
Last Modified: 2012-05-05
hi folks, i'm in a trouble dat i want to add both hours and minutes taken i.e sub-total and grand total of that addition. i have seen many forums but they have given for only hours to be calculated. but i need both to be calculated simultaneously.
0
Comment
Question by:digmax
  • 2
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 22609486
You should be able to use either the Date structure, or a TimeSpan to do the necessary calculations to get hours and minutes.

Example:


Dim dt1 As New Date(2008, 1, 1, 23, 0, 0)

Dim dt2 As Date = Now
 

Dim ts As TimeSpan = dt2.Subtract(dt1)

Dim hours As Integer = ts.Hours

Dim minutes As Integer = ts.Minutes

Open in new window

0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 22610137
It's a little unclear if the asker wants total minutes taken, in which case the code above needs to be tweaked slightly

Dim totalMinutes As Integer = 60 * ts.Hours + ts.Minutes

Other than that, TheLearnedOne is bang on (as usual)
0
 
LVL 1

Author Comment

by:digmax
ID: 22612035
no actually i need to add the total time in the gridview. but the problem coming is its in hrs and mins format, so how to make the addition i.e subtotals
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 22616249
Are you saying that you have a string column that has hours and minutes, and you need to calculate a sum?

Example:

Duration      Decimal
-----------      -----------
1:30            1.5
1:34            1.566667
1:35            1.583333
1:45            1.75
======      =======
6:24            6.4

Formulas
-----------
Decimal = Hours + (Minutes / 60)
Time = INT(Decimal) & ":" & (Decimal - INT(Decimal) * 60)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now