Solved

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

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Stop Git from being my repository 1 49
C# LINQ 5 43
asp.net repeater server posting 5 38
async questions 5 48
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

734 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