473,385 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Issues calculating total hours using timespan

1
I have created a form with two datetimepicker showing only hours (start and end times). I have timespan calculating the total hours, but when it goes to the next day, it adds 24 hours. For example, from 9PM to 11PM it calculates 2 hours total, but when it goes from 9Pm to 12AM, it jumps to 21 hours. I want it show 3 hours instead, but not sure how to do this. Heres what I have so far:

Expand|Select|Wrap|Line Numbers
  1. timeEnd.Format = DateTimePickerFormat.Custom;
  2. timeEnd.CustomFormat = "hh:mm tt";
  3. TimeSpan ts = timeEnd.Value - timeStart.Value;
  4. lblTime.Text = "Total Time: " + (ts.Duration());
  5.  
Dec 5 '10 #1
0 1823

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: John | last post by:
hey all..... alright, I am frusterated to the point of throwing my machine out the window (this board went down, trying to find stuff on google, this has been a nightmare) so I hope you guys can...
5
by: Kenneth P | last post by:
Hi, I'm having a problem to measure the time between two events Dim StrStart As DateTime = DateTime.Now.ToString("h:mm:ss.fff") .... do some stuff ... Dim StrEnd As DateTime =...
5
by: Larry Bird | last post by:
I want to use TimeSpan to determine the differences between two date to include time. My input data is in the following format: 12/25/2004 12:23:00 AM or 01/05/2005 11:59:00 PM How do I get...
2
by: dath | last post by:
Hi, Not really a programmer here, but have been forced into the role. I was asked to develop a basic time sheet for employees to enter time. I developed the Table without a problem. I then...
1
by: reshmaarora22 | last post by:
hi i have i table called Description which has details about StartTime , EndTime and ScheduleDate of the various Transaction occuring daily.I want to fetch total time spend on a particular...
3
by: Dan | last post by:
I'm trying to calculate the total work hours between a start and end date, and also working out an end date by adding a number of work hours to a start date. Can anyone recommend a decent formula...
1
by: r786amesh | last post by:
Hello Everybody, My question is I want to display Nested gridview footer total by using javascript. its very urgent pls help me... thnx ramesh
1
by: silversubey | last post by:
I am using a query to total hours (Cltbudget.CBudhours) and dollars (CltBudget.CBudFee) Grouped by client names (Cltbudget.CBudCltName). here is the Query: SELECT CltBudget.CBudCltName AS Client...
4
by: sumit kale | last post by:
Hi, Can somebody help me resolve my problem ? I am getting error when calculating total using unbound textfiled in subform. I have a main form called purchase_register_master and a subform...
2
by: NareshN | last post by:
Hi All, I am calculating totaltime of the employee for each day.I want weekly totaltime working hours.I am using for loop to calculate totaltime for 1 week.But i am storing Total time in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.