Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Dear sir,

I have one issue. i am working on web based application in ASP.Net and C#.

I have two column one is hour and another one is minute column in datagrid. i want to display total hours and minutes in same column

it should display like this--

suppose 5.70(means 5 hour and 70 minute). it should display 6.10(means if minute is more than 60,it should add with hour and rest minute should display as well(like 6.10). How i will do using C#.
Posted
Updated 22-Nov-13 18:21pm
v2

1 solution

Not a big deal. Just giving you logic to achieve this.

First convert the Hours to Minutes.
5 Hours * 60 Minutes = 300 Minutes

Now add Minutes to Converted Minutes
70 Minutes + 300 Minutes = 370 Minutes

Now convert the Minutes to Hours
370 Minutes / 60 Minutes = 6 Hours(Integer)
370 Minutes Mod 60 Minutes = 10 Minutes
6 + .10 = 6.10

By using string concatenation you could display as single string.
 
Share this answer
 
Comments
♥…ЯҠ…♥ 23-Nov-13 8:03am    
Nice... deserves 5!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900