converting string to timespan

Hello experts I have a value stored in a database as a string like so: hh:mm:ss  for example 00:34:32 which is 34 minutes and 32 seconds.  I need to convert this into a hours like so .5 hours.  How can I accomplish this?  
Who is Participating?
Here is a more generic solution

string s = "00:34:32";  //your input is a string, right?
string[] strArray = s.Split(new char[] {':'});  //separate the string into three parts
TimeSpan ts = new TimeSpan(
      Convert.ToInt32(strArray[2]));  //create the time span
double nHour = ts.TotalHours;  //number of hours in double
nHour = Math.Floor(nHour/0.5) * 0.5;  //do this if you want to round down to half hour

Hope that helps
Try this...
Dim myTime As DateTime = "#00:34:32#"
Dim myAltTime As String = CStr(Math.Round(CInt(myTime.Minute) / 60, 1)) & " hour(s)")

It should output "0.5 Hour(s)"
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.