Solved

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

Posted on 2009-07-16
2
289 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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