Solved

# How to convert times from String to Decimal value

Posted on 2005-03-31
Medium Priority
438 Views
Hi..
How do you convert a string time to the decimal value?

I have a 'table' of total hours need to convert them to decimal so I can sum them..

"12:30:00"   = 12.5
"08:45:15"   =  8.7525
"01:20"     = 1.33333333

thanks
0
Question by:JElster
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
1 Comment

LVL 10

Accepted Solution

eternal_21 earned 320 total points
ID: 13673996

System.TimeSpan.Parse("12:30:00").TotalHours = 12.5d
System.TimeSpan.Parse("08:45:15").TotalHours = 8.75416666666667d
System.TimeSpan.Parse("01:20").TotalHours = 1.33333333333333d

* Note that 15 seconds is not 1/400 of an hour, but 1/240 of an hour = 0.00416666666667d.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
###### Suggested Courses
Course of the Month13 days, 21 hours left to enroll