Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculation not showing decimals correctly

Status
Not open for further replies.

radder33

IS-IT--Management
Nov 26, 2009
66
0
0
DE
Hello

I have a calculation in a query to create some percentages but its only showing whole numbers. To test I did the percentage column and just a normal divide column to show the decimals and they just show 0

For example I have the below

2104 / 64394 = 3.00% or 0.03000000

I would expect to see

2104 / 64394 = 3.27% or 0.03267385

Can anyone suggest why this is happening?
 
hi,

Please post all your related SQL code.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
If you have no functions in your query, then it is likely being caused by the underlying table-field formats. Check the underlying formats, and make sure they are not rounded down via the allowed double/decimal numbers, or by using integers. Make sure they are set to something like double or decimal, and that they have however many number decimal spaces you need.

Or if you just need the end result correct, and don't care about the #s coming into it from the tables, then use the appropriate conversion function to convert the inputs to the correct formats before running the division.

So if you want to do it just in the query, you should be able to do this:

Code:
SELECT MyPercentField:CDbl(TopValue/BottomValue)

and if you need to round it to say 4 decimal places:

Code:
SELECT MyPercentField:Round(CDbl(TopValue/BottomValue),4)

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top