Solved

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

Posted on 2009-07-16
2
294 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 86

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

630 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