× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Convert fraction part of hours into minutes using sql or c#

Asad Saeeduddin
Oct 08, 2015
<p>You could do this:</p> <pre><code>var mins = TimeSpan.FromHours(4.5).Minutes; </code></pre> <p>Note that "converting the fraction part of hours into minutes" is a totally separate concern from displaying timespans in a certain format. To get the <code>"04:30"</code> output you've mentioned in your question, you could do:</p> <pre><code>var fmtString = TimeSpan.FromHours(4.5).ToString(@"hh\:mm"); </code></pre> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/30722152/Convert%20fraction%20part%20of%20hours%20into%20minutes%20using%20sql%20or%20c#/30722174">Stack Overflow</a>.</p>
comments powered by Disqus