Conversion from day to hours


Hi All,

I have a Timespan variable with value 4.04:00:00. I want to convert this into hours, The output should be 100:00:00.
Can anyone please help me with the function which i need to use.

Thank You :slight_smile:


@Reshma Actually this way, see if it works for others.



Thanks @vvaidya .
Using Variable.TotalHours.ToString, I am getting the timespan in hours, but not exactly. For eg. If the input is 7.22:30:00, the output should be 190:30:00. But I am getting 190.5.

Using Variable1.tostring(":mm:ss") with any output results like 100:mm:ss and 190.5:mm:ss.

where I am doing wrong?


I suggest you to try this:


Can you Increase the duration up to days (not hours) and paste the screenshot.

I may be wrong but,

For runtime.hours

Out put is:

00:23:59:59 --> 23

01:23:59:59 --> 23

Where as

runtime.TotalHours 01:23:59:59 --> 47


This should help

Seconds=  varTimeSpan.TotalSeconds

String.Format("{0:00}:{1:00}:{2:00}", seconds / 3600, (seconds / 60) Mod 60, seconds Mod 60)