Advertisement

04.27.2007 at 02:55PM PDT, ID: 22539582
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.2

Rounding Down Money or Truncating to two numbers to the right of the decimal

Asked by Data-Man in MS SQL Server

Tags: , , ,

I'm having a rounding issue in SQL Server 2000.  I guess I shouldn't say rounding issue...it's doing exactly what I'm telling it to do...I'm in need of a little tweaking of my code

Let's say I have $23.87 to distribute amoung 3 people with the following breakdown

Person 1 gets 13/22 which equals $14.105
Person 2 gets 3/22  which equals $3.255
Person 3 gets 6/22 which equals 6.510

I'm using this formula
SELECT CAST(23.87 * ((.13*100)/22) AS SMALLMONEY)

At the end of the week I created a report and sum on each persons distribution...the number is greater than what I started with becuase of rounding.
Person 1 gets $14.11
Person 2 gets $3.26
Person 3 gets $6.51

If you add them all up it equals 23.88 (Over by 1 penny).  It may seem insignificant, but when this is done 10's of thousands of times it really starts to add up.

What I would like to do is truncate the down to two numbers to the right of the decimal point in the calculation.  I can then assign the extra penny if there are is one.

I tried ths, but it rounds and then truncates.
SELECT CAST(CAST(23.87 * ((.13*100)/22) AS DECIMAL(10,2)) AS SMALLMONEY)

I need to truncate the data so it looks like this 14.10 and 3.25...bascially, it should always round down.

Can someone please point me in the right direction?

Thanks
Mike
Start Free Trial
[+][-]04.27.2007 at 06:08PM PDT, ID: 18993091

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MS SQL Server
Tags: round, down, sql, money
Sign Up Now!
Solution Provided By: _agx_
Participating Experts: 1
Solution Grade: A
 
 
[+][-]04.27.2007 at 08:59PM PDT, ID: 18993415

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43