Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
ccnorris #1
Rounding to nearest 100
Hi all. I am new to working with formatting numbers. I have a form inputting
sales totals into a Microsoft Access database. I need a field for total sales
and then another field for the total rounded to the nearest 100. I tried using
the Round() function but it is just rounding to the nearest integer. Most of
my numbers are in the thousands and need to be rounded to the nearest 100 (and
possibly in the future the nearest 1000). For example, the total sales for one
day is 2587. I would like this number rounded to be 2600. I have set up
coding to format the number before it is inserted into the database. The
coding I have tried to use so far is <cfset RoundTOTAL = Round(#DTOTAL#)> where
"RoundTOTAL" will be my rounded sales total and "DTOTAL" is the daily total
sales. When "DTOTAL" equals 2587 the "RoundTOTAL" in the database is
displaying as 2587. I assume I need to add something to my Round funtion but
am unsure of what. Any help would be greatly appreciated!!!
ccnorris Guest
-
Finding nearest...
A client of mine wants to impliment a feauture that will let the user find the company's neerest location based on the zip code the user enters. Is... -
'How do they do that' long/lat/nearest in miles to an attraction
Hello I wonder if anyone can help. I would like to know how certain sites: http://aboutbritain.com/ArundelCastle.htm, and... -
Snap Sprites to Nearest Grid Space
Hi, I have this problem which I need the solution to ASAP. I have started developing a program which requires snapping of sprites to nearest... -
Rounding Up
Is there a way to make your numbers always round up. Ex: if the number is 0.0341 it will round to 0.035 Brent -
Query, Join on nearest
Hello, I am in a position where i need to create a query where i must join two tables on the nearest value. Imagine i have 2 tables, tbl_Trade... -
Stressed_Simon #2
Re: Rounding to nearest 100
You have to multiply or divide it by multiples of ten then round it then
reverse the multiplication or division. Like so:
<!--- set initial value --->
<cfset myValue = 2587>
<!--- round to the nearest hundred --->
<cfset newValue = Round(myValue / 100) * 100>
<cfoutput>#newValue #</cfoutput>
Stressed_Simon Guest
-
ccnorris #3
Re: Rounding to nearest 100
Simon,
Thank you so much for you help! It works great! :)
Thanks again,
Carolyn
ccnorris Guest
-
ccnorris #4
Re: Rounding to nearest 100
Hi again. If you don't mind I need a little more information.
For my initial question I asked about rounding to the nearest 100. I have now
created a new form to input support numbers. Most are coming in with totals
with two integers (ie, 35). For this section I assume I am going to set the
round to the nearest 10. However, what If I get a total in that exceeds the 2
digits and is in the 100s? I think I need a way to round to the nearest 10 OR
nearest 100 depending on the data. In this case do I need to set up if
statements?
Thanks in advance for any help!
ccnorris Guest
-
Stressed_Simon #5
Re: Rounding to nearest 100
Thank you that is very flatering.
For what you are trying to achieve you will need to use if statements. You'll
have to check the range of the current value amd the format the numbers
accordingly. If you need help with that then please post agina and we'll see
what we can do.
Stressed_Simon Guest



Reply With Quote

