ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Convert TimeSpan to Days and Hours in C# .Net<p>Please consider this example</p> <pre class="brush: csharp">TimeSpan timeSpan = new TimeSpan(); DateTime dtStart = DateTime.Now; DateTime dtEnd = DateTime.Now.AddHours(1.5).AddDays(1); timeSpan = dtEnd.Subtract(dtStart); double hours = timeSpan.Hours + (timeSpan.Days * 24); string time = string.Format(&#34;{0}hours and {1}minutes&#34;, hours, timeSpan.Minutes);</pre> <p>You can find the total hour as below code.</p> <pre class="brush: csharp">double hours = timeSpan.Hours + (timeSpan.Days * 24);</pre> <p>And this will also give you total hours</p> <pre class="brush: csharp">int totalHours = (int)timeSpan.TotalHours;</pre> <p>This will suppress the minutes and give you only hours.</p>https://www.aspforums.net:443/Threads/104443/Convert-TimeSpan-to-Days-and-Hours-in-C-Net/https://www.aspforums.net:443/Threads/104443/Convert-TimeSpan-to-Days-and-Hours-in-C-Net/Tue, 09 Sep 2014 02:32:33 GMT