473,322 Members | 1,307 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How can I trim decimal spaces of a query result?

Haitashi
I have a variable that contains results of a query. However, when the results (which calculates the grade average of a student) comes back with decimals, the display in really long like: 86.33333333.

If I get a result like the one above, I want the application to trim it down to just 86.33. How can I achieve this? I thought I could use "TRIM" but don't know how to go about that.

THANKS!
Apr 30 '08 #1

✓ answered by acoder

Use the NumberFormat function with a mask of, say, "99.99".

5 4606
acoder
16,027 Expert Mod 8TB
Is it a string or a number?
May 1 '08 #2
It's a number. This is the query that populates that variable:

Expand|Select|Wrap|Line Numbers
  1.     <cfquery name="Variables.qTotal" datasource="#Variables.sDatasource#">
  2.         SELECT sum_completion = ((SUM(convert(real,is_complete)) / #Variables.qData.recordcount#) * 100)
  3.         FROM dbo.vw_activity_task_list
  4.         WHERE (class_section_id = #Session.oEnvironmentContext.sectionID#)
  5.         AND (SyStudentID = #Attributes.nStudentID#)
  6.         AND (can_grade = 1)
  7.     </cfquery>
May 1 '08 #3
acoder
16,027 Expert Mod 8TB
Use the NumberFormat function with a mask of, say, "99.99".
May 1 '08 #4
Perfect! That worked and I learned a new function. This will help me a lot. THANKS!
May 1 '08 #5
acoder
16,027 Expert Mod 8TB
You're welcome. Glad to help.
May 2 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Dave Bovey | last post by:
I created a church database in Access 97 that contain the typical Name, Address, and Phone Number information fields. I had a number of different reports to print query data in different formats. ...
3
by: Andy B | last post by:
I've tried using Trim or RTrim to strip trailing space characters from my data. When I check on the transformed data space characters are still there. We have an address table containing two...
4
by: MLH | last post by:
My table has an autonumber field and a text field named . Many records have unnecessary spaces padding the front and end of - at least, I think they're spaces. The look like spaces to me. ...
9
by: Durgesh Sharma | last post by:
Hi All, Pleas help me .I am a starter as far as C Language is concerned . How can i Right Trim all the white spaces of a very long (2000 chars) Charecter string ( from the Right Side ) ? or how...
11
by: Darren Anderson | last post by:
I have a function that I've tried using in an if then statement and I've found that no matter how much reworking I do with the code, the expected result is incorrect. the code: If Not...
22
by: Terry Olsen | last post by:
I have an app that makes decisions based on string content. I need to make sure that a string does not contain only spaces or newlines. I am using the syntax 'Trim(String)" and it works fine. I...
1
by: zufie | last post by:
I want to remove all white spaces from the beginning and end of the string. I am using the following SQL code: SELECT TRIM(' Sample '); I am supposed to receive the following Result: ...
8
by: jonosborne | last post by:
Hi, Im sure the TRIM function works fine, otherwise there would be thousands of people worldwide kicking up a right fuss. But for some reason it is not returning the desired result. I have a...
8
by: Michael786 | last post by:
Hi. I am using access 97 and am trying to run a query that will crunch up all data in a field and thus removing all spaces. For example I have a field called Address1: Example data: 12 Murray...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.