Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 439
  • Last Modified:

How to convert times from String to Decimal value

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
JElster
Asked:
JElster
1 Solution
 
eternal_21Commented:

  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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now