Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Formatting Time Span


Message #1 by "Hugh McLaughlin" <hugh@k...> on Fri, 31 Jan 2003 18:08:59
Hello Everyone and thanks for your help in advance.  I have an 
application that logs a start and finish time, then calculates the 
difference in time using the Timespan function.  I then use the code:

TotalCell.Text = "Total Hours Worked = " & TotalHours.TotalHours.ToString

However, this code give me an answer like 38.3981316666667.  I want to 
express the time in hours, but I only want two places after the decimal.  
I am not sure how to get this formatted (or rounded) correctly.  Any help 
would be greatly appreciated.  Thanks.
Message #2 by "Lewis Bass" <lewis@t...> on Fri, 31 Jan 2003 14:15:25 -0800
 try this
TotalCell.Text = "Total Hours Worked = " &
math.round(TotalHours.TotalHours,2)


-----Original Message-----
From: Hugh McLaughlin [mailto:hugh@k...]
Sent: Friday, January 31, 2003 6:09 PM
To: ASP.NET
Subject: [aspx] Formatting Time Span


Hello Everyone and thanks for your help in advance.  I have an
application that logs a start and finish time, then calculates the
difference in time using the Timespan function.  I then use the code:

TotalCell.Text = "Total Hours Worked = " & TotalHours.TotalHours.ToString

However, this code give me an answer like 38.3981316666667.  I want to
express the time in hours, but I only want two places after the decimal.
I am not sure how to get this formatted (or rounded) correctly.  Any help
would be greatly appreciated.  Thanks.


  Return to Index