[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

calc minutes to houre

Posted on 2007-10-01
5
Medium Priority
?
254 Views
Last Modified: 2010-05-18
time calc problem
i have this resuat of time :
10.60
its need to be 11 hours
the .60 is minutes
its need to be turn to 1 houre
i do this code ant its work good :

decimal time =(decimal)10.60;
decimal t = time % 2;
textBox2.Text = t.ToString();
decimal res =(t/60) * 100;
time = time - t;
decimal tot = time + res;
textBoxEx2.Text=tot.ToString();

now if the total hour is 10.70 insted of 10.60
i need to get 11 hours and 10 min = 11.10
i am geting wrong resualt 11:16

how can i fix that ?
thanks ...
0
Comment
Question by:Tech_Men
  • 2
  • 2
5 Comments
 
LVL 21

Expert Comment

by:surajguptha
ID: 19992558
Generally what are you using this code for? what are you trying to do ?
0
 

Author Comment

by:Tech_Men
ID: 19994027
i mange but i still have a small problem
if the diff is a round number
i need to add the number .00

i need to check if the num is round and if he is round i need to attach the .00
if i get the num 8
i need to change it to 8.00
thanks..
0
 
LVL 21

Expert Comment

by:surajguptha
ID: 19994069
If you are looking to check if the number is round. you should look at Math.Round() function
0
 
LVL 22

Accepted Solution

by:
JimBrandley earned 2000 total points
ID: 19994229
This will do what you want:
decimal time = (decimal)10.70;
int hours = (int)time;
time = time - hours;
int minutes = (Convert.ToInt32(time * 100));
int extraHours = minutes / 60;
minutes = minutes % 60;
int totalHours = hours + extraHours;
time = Convert.ToDecimal(totalHours) + Convert.ToDecimal(minutes ) /100;

Jim
0
 

Author Comment

by:Tech_Men
ID: 19994361
great
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question