how to calculatethe time?

  • Thread starter Thread starter Alan Ho
  • Start date Start date
A

Alan Ho

e.g.

Label17.Text=((DateTime.Parse(addEndText.Text))-(DateTime.Parse(addStartText
..Text))).ToString();

how can i calculate 10:00:00 - 20:00:00 then the result will ouput integer
and = 10

Thanks
 
Alan said:
e.g.

Label17.Text=((DateTime.Parse(addEndText.Text))-(DateTime.Parse(addStartText
.Text))).ToString();

how can i calculate 10:00:00 - 20:00:00 then the result will ouput integer
and = 10

Thanks

Do you just want the hours? If so, take the absolute value of the Hours
property of the TimeSpan that is returned by your date math operation:

TimeSpan ts =
DateTime.Parse(addEndText.Text)-DateTime.Parse(addStartText.Text)
Label17.Text = (Math.Abs(ts.Hours)).ToString();
 
thx
If i want to 10:30:00 - 20:00:00
it's possible the output can be 10.5>?
thanks
 
fixed it..thx

Alan Ho said:
thx
If i want to 10:30:00 - 20:00:00
it's possible the output can be 10.5>?
thanks
Label17.Text=((DateTime.Parse(addEndText.Text))-(DateTime.Parse(addStartText
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top