Solved

convert minutes to hours and check if entering less then 60 minutes

Posted on 2009-07-16
2
286 Views
Last Modified: 2012-05-07
I want to convert minutes to hours by entering a value in minutes, however if I enter a value less then 60 minutes then I get zero

Here is my code snippett

decimal Cost = (Minutes / 60 * hourRate);

what am i doing wrong

0
Comment
Question by:mugsey
2 Comments
 
LVL 14

Accepted Solution

by:
flob9 earned 500 total points
ID: 24867890
try this :

decimal Cost = (((decimal)Minutes) / 60 * ((decimal)hourRate));
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 24870682
You could also use the TimeSpan.FromMinutes() method like this:

            int Minutes = 45;
            decimal hourRate = 10.25M;
            decimal Cost = (decimal)TimeSpan.FromMinutes(Minutes).TotalHours * hourRate;
            MessageBox.Show("Cost = " + Cost.ToString());

See: http://msdn.microsoft.com/en-us/library/system.timespan.fromminutes.aspx
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now