Add decimal hours to timespan
Asked Answered
V

1

5

I have a Decimal value representing fractional number of hours in a time interval.

Now I need to sum this value to a TimeSpan, but I cannot find an effective method to do it.

My solution, for now, is to do something like this:

myTimeSpan + new TimeSpan(0, 0, Math.Abs(decimalHours * 3600))

Is there any better way to solve my issue?

Verrucose answered 4/10, 2012 at 10:1 Comment(0)
F
12

how about

myTimeSPan + TimeSpan.FromHours((double)decimalHours);
Forebrain answered 4/10, 2012 at 10:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.