[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
Solved

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

Posted on 2008-09-30
Medium Priority
717 Views
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
Question by:digmax
• 2

LVL 96

Expert Comment

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
``````
0

LVL 24

Expert Comment

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

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

Bob Learned earned 750 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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
###### Suggested Courses
Course of the Month20 days, 2 hours left to enroll