how can i calculate total time in using c#

may i know how can i calculate the total time in using c# comprising hour minutes, and second
the example i could found in the Internet only add up hour and minutes.
string hour1="48:40";
string hour2 = "45:35";
TimeSpan ts = new TimeSpan(int.Parse(hour1.Split(':')[0]),int.Parse(hour1.Split(':')[1]),0);
TimeSpan ts1 = new TimeSpan(int.Parse(hour2.Split(':')[0]),int.Parse(hour2.Split(':')[1]),0);
TimeSpan total = ts + ts1;
and what does the [1] and [0] means
Posted On: Tuesday, November 27, 2012 Total Views: 39
View Complete with Replies

Related Messages:

How do I calculate some thing between two columns in a gridview control   (13 Views)
I have an easy gridview control on .aspx page. It has one combo box in the gridview control and rest of the columns in the gridview control are all bound controls.
When the user picks some thing from combo box I should multiply the number (picked from the combo box) with other number in the same row (meaning in a various column on the same row). I want to do all this in server controls not thru JQuery or Javascript. Here I'm so far and
View Replies !
hwo to calculate dates between two dates   (10 Views)
Can some body pls advise me a way to receive all dates b w two date for instance
14 10 2010
22 10 2010
so there are 9 days b w two datesi wanted to do it
View Replies !
How do I calculate time difference   (9 Views)
For a project I'm working on right now I want to be able to calculate the
time difference b/w to given times (24 hour format) and two given dates
For instance:
Case 1: On the same date
The difference b/w 11:30 28 09 2005 and 14:45 28 09 2005 being 03:15
Case 2: On various date
The difference b/w 21:30 28 09 2005 and 10:45 29 09 2005 being 13:15Right now the input is setup as 5 text boxes (dateup, datedown, timeup, timedown, totaltimediff). Is it possible to use that configuration and somehow receive the time
difference The aim is to be able to enter the the date and time values and immediately view a calculated difference in a totaltimediff textbox.
I'm thinking the scenario is like this:
1. User enter date up in first text box(dateup) - 28 09 2005
2. User enter date down in second text box(datedown) - 29 09 2005
3. User enter time up in third text box(timeup) - 21:30
4. User enter time down in fourth text box(timedown) - 10:45
5. Onchange of fourth text box, the duration is calculated and result is inserted into fifth text box (totaltimediff).I'm uncertain if how can i bet do this.
View Replies !
ho to retreive totalrecords in   (7 Views)
i was attempting to retreive totalrecords and put it in a text feild
How do I do that
Pls Assist
View Replies !
Re: creating calculated extra coulmn in a datagrid   (8 Views)

I want include a calculated column as part of my columns in the datagrid.
Let s say: the datagrid gets the columns: col1, col2, col3 from the db
I need to add another column in my datagrid: col4
But col4 will be: col4= col1 + col2 - col3 (just an example)
I guess I should do this in itemDataBound , right
But in itemDataBound How can I make that happen:
col4= col1 + col2 - col3
Also, how should be the datagrid column: col4 defined in the datagrid aspx page: boundcolumn or itemTemplate
View Replies !
Math with .NET? total of gridview columns   (6 Views)

I was just tasked with making a gridview of a couple of columns.
Column one is a name and columnd 2,3 and more.. are check boxes that will indicate the job has been finished or not. What I have to do is at the bottom of the column or in a textbox display the done. I've never worked with the math in .net so I've no clue on how can i tally a row or column. Does anybody have any good resources to display how can i do this, or a small snippet of code snippet that will point me to the right direction I will be saving the data to a db that I do know how can i wirte and retrive the data, I'm just now sure on how can i do the math.
View Replies !
summing total of datagrids   (6 Views)
http: showthread.p...hreadid=307621
View Replies !
recalculate in datagrid  (4 Views)

everybodyi want ur assist, is there anybody know How do I write the function will calculate the total for the items in datagrid.or do you've any related web site, you can send to me,ok
View Replies !
[RESOLVED] itemdatabound doubles total   (2 Views)
The framework using is 3.5.
Situation: I've a page that I call a stored procedure that returns two results. I generate a dataset and then from that generate two dataviews that one can have more than one records.
Problem: During the rptInvoice_itemDataBound of the repeater I'm adding the amount value. The difficulty is it is always double what it should be. If I've one result with a total of $100 it displays $200. If I've two records each with $150 the total shown is $600. It is like its looping two times per row but only displaying the row once.
Any thoughts on why my total is double
Here is my code snippet.
Dim cFn As clsfunctions = New clsfunctions
Dim cEncDec As clsEncryptDecrypt = New clsEncryptDecrypt
Private m_Total As Decimal
Public Property Total() As Decimal
Return m_Total
End Receive
Set(ByVal Value As Decimal)
m_Total = Value
End Set
End Property
Protected Sub Page_Load(ByVal sender As Object ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
lblTotal.Text = Total
End If
End Sub
Private Sub sbFillPage(ByVal iPaypalTransactionID As Integer)
'Receive info for receipt page
Dim dsReceiptInfo As DataSet = cFn.fnGetReceiptInfo(iPaypalTransactionID)
Dim dvPaypalInfo As DataView = New DataView(dsReceiptInfo.Tables(0))
Dim dvInvoiceInfo As DataView = New DataView(dsReceiptInfo.Tables(1))
If dvPaypalInfo.Count > 0 Then
lblOrderNum.Text = iPaypalTransactionID
lblOrderDateTime.Text = dvPaypalInfo(0)("xxx")
lblFirstName.Text = dvPaypalInfo(0)("xxx")
lblLastName.Text = dvPaypalInfo(0)("xxx")
End If
lblInvoiceCount.Text = dvInvoiceInfo.Count
rptInvoice.DataSource = dvInvoiceInfo
End Sub
Protected Sub rptInvoice_itemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeateritemEventArgs) Handles rptInvoice.itemDataBound
If e.item.itemType = ListitemType.Header Then
Total = 0
End If
if ((e.item.itemType = ListitemType.item) _
OrElse (e.item.itemType = ListitemType.Alternatingitem)) Then
Total += CType(e.item.Dataitem, DataRowView)("invoice_amt")
End If
End Sub
HTML Code:
"rptInvoice" runat="server" OnitemDataBound="rptInvoice_itemDataBound">


View Replies !
Re: How do u display total number of rows in a table into a label?   (1 Views)
i am newbie.
i use sql server 2005 and Visual Studio 2008.
I am using and for my web site.
I've a table with number of rows 50000.
i need to show the number of rows at my table in a Label when the page is on load.
so can you provide me the code snippet or the hint thanks
my second question is.
my table has around 50,000 items.
and I've a search box, it look like this
str= select * from mytable where item='car'
the item Car is located in my table in row number of 45,000.
I think when i search from the table where the item is car, then it will search row by rows, then as the number of rows become huge, it will be so late to find the result.
so is there any method how can i search from table with good speed of searching
View Replies !
Re: [2005] Recalculate Formview on Formview Insert   (2 Views)
I have 2 formviews the first SELECTS the SUM of one of my fields in my tablr and shows the result in a label. The second contains a form that submits data into this table.
When i submit a new value into the second form i wana the first form to edit.
I recently have:
If IsPostBack Then
Dim formview3 As FormView = FormView1.FindControl("formview3")
End If
On SqlDataSource1_Inserted, imageButton1_Click, Page_Load AND Page_PreRenderComplete but it seems to be an insert behind in its calculation any solutions where I'm going wrong
View Replies !
Re: Master Page totally loaded?   (3 Views)

How do I know if the masterpage is totally loaded
Imagine that you've a label in a masterpage with in it.
And one children of that masterpage needs the contents of that label you do this:Code snippet:
Protected Sub Page_LoadComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
lblDateinChildren.Text = CType(Master.FindControl("lblDateinMaster"), Label).Text
End Sub
But when the children page loads, there is no contents in lblDateinChildren.
I think that this occurs because the masterpage did not assign the contents to it is lblDateinMaster.
View Replies !
Re: Automatically calculate and populate   (5 Views)

I am attempting to find way to automatically calculate and populate to Label
Adding up two two textboxes and then automatically populate to Label.
I can receive it to work with onclick funtion but I really don't wana that.
View Replies !
GridView - inserting total line in detail section   (16 Views)
I have a GridView that shows a list of cost codes for a specific job (see attached example). User wants to have a line inserted after each break on cost code snippet displaying total quantity (nned to add up quantity for each line). Is this possible Any suggestion would be comprehended.
View Replies !
How do I calculate values of a datacolumn from 2 datatable values?  (7 Views)

I've a dataset with 2 dataTables named "Office" and "DriveInfo." The schema for "Office" is:Code snippet:" target="_blank">http: 2001 XMLSchema">;The schema for "DriveInfo" is:Code snippet:" target="_blank">http: 2001 XMLSchema">;I am adding a new datacolumn named "Changed" to the datatable programmatically.I need to calculate the values of datacolumn "Changed" programmatically. The values should be equal to Office.PercentFree - DriveInfo.PercentFree.Finally I need to bind the data to a datagrid that should have these columns: servername driveletter, Disk Size, Disk Free, Disk Used, Free, Changed , Office. Any assistance would be greatly appreciated
View Replies !
[2005] going totally nuts with user controls   (4 Views)
I'm going totally nuts here.
I hope somebody can assist me here I have been going nuts for 2 days now.
I have a page where I edit and insert items. (for this particular web site it is horses.)
Each horse has a set of properties. I made user controls for all properties.
all user controls contain an easy dropdownlist with inside:
value: an integer (FK to the property table inside the db)
show: the name of the property being read out the db
also before databinding the dropdownlist with values out of the db I have got a difficult coded one : "NOT AVAILABLE".
Not available will fundamentally insert NULL inside the db row.
for inserting horses, I just put an html table inside a panel and put textareas, textbox, and all the user controls there. (I can thus call all these controls directly in my code-behind file)
INSERTING works perfectly. It is the updating part that is making me go nuts:
I now use these user controls as templatefields inside a formview (or detailview, I tried both) for the updating part.
Here is a small example:for inserting, an click-event is fired on the button "new"
all my values are checked or interchanged:Code snippet:
Dim ras As Object = RaceSelect1.SelectedRace
If Not ras.ToString = String.Empty Then
ras = CInt(RaceSelect1.SelectedRace)
ras = sqlintnull
End If
here if in my usercontrol, I selected a race that is in the db then it will use that value.
if instead "not available" is selected, the value for "not available" is empty and so a variable sqlintnull is entered.
this @ras is then used as a parameter for my stored procedure. I do this for about 15 parameters.
this work perfectly because these controls are not inside a detailview of formview.for updating (the info is thus already in the db) I need to show it in a formview of detailview. but if the user clicks "edit" he must be able to alter the values.
when in edit mode if the user chooses "not available" in the usercontrol dropdownlist I receive an invalid cast to error message because inside the dropdownlist it is a STRING and not DBNULL.
this is why I need :Code snippet:
Dim ras As Object = RaceSelect1.SelectedRace
If Not ras.ToString = String.Empty Then
ras = CInt(RaceSelect1.SelectedRace)
ras = sqlintnull
End If
but here instead as in inserted:Code snippet:
Dim RaceSelect1 as UserControl = CType(Formview1.FindControl("RaceSelect1"), UserControl)
Dim ras As Object = RaceSelect1.SelectedRace
If Not ras.ToString = String.Empty Then
ras = CInt(RaceSelect1.SelectedRace)
ras = sqlintnull
End If
(the bold does not work , I can't seem to receive into my public property meaning it does not recognises the user control)ok then I tried this:
I interchanged 1 usercontrol with a plain dropdownlist linked to a sqldataconnection.
if I then go to the code snippet behind : (didn't put all the code snippet, just the logic here )...
Code snippet:
and then
Code snippet:
it worksso why does not this also work on user controls ...Code snippet:
what is the use of usercontrols if this does not work
any assist would be great
View Replies !
executing total in asp editable gridview  (14 Views)
This has been causing me grief for days. I placed here http: www.dreaminco...-and-gridviews but tsaid its more jsp or c# ..can anybody assist pls
View Replies !
calculate number of days between two dates in MVC-3  (26 Views)

I have to count the days b/w given start and end dates in MVC-3
so How do I do this
code of my class files are:
set receive fileusing System;
using System.collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
namespace LeaveModule.Models
public class LeaveSet

public int user_id { receive; set; }
[DisplayName("Start Date")]
public DateTime leave_start_date { receive; set; }
[DisplayName("End Date")]
public DateTime leave_end_date { receive; set; }
public string leave_description { receive; set; }
public decimal leave_days { receive; set; }

and code of 2nd class file for fetch the user data..
using System;
using System.collections.Generic;
using System.Linq;
using System.Web;
using ProjectManagementSystem.Models;
namespace LeaveModule.Models
public class LeaveSetfetch
TimeSpan ts;

public static IList all()
IList result =

if (result == null)

HttpContext.Current.Session["leave"] = result =
(from l in new ProjectManagementSystemEntities3().leave_master
select new LeaveSet
user_id = l.user_id
leave_start_date = l.leave_start_date,
leave_end_date = l.leave_end_date,
leave_description = l.leave_description,
ts = l.leave_end_date.Subtract(l.leave_start_date),
leave_days = l.leave_days,
is_valid = l.is_valid,
return result;
how to do these in mvc
View Replies !
How do I calculate the node of tree  (4 Views)
I am using I've generate a tree with the assist of levels.
Now i need to count all member of particular member. How do I do that.
View Replies !
Label displays total  (6 Views)
I have got this code snippet:

I wana amount_01 to show area_01 * rate_01 when the two textboxs' values's are entered and this is done with out a button.
How can I do this
View Replies !