#newValue # [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => Stressed_Simon [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 2 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> Rounding to nearest 100 - Coldfusion - Advanced Techniques

Rounding to nearest 100 - Coldfusion - Advanced Techniques

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. ...

  1. #1

    Default 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

  2. #2

    Default 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

  3. #3

    Default Re: Rounding to nearest 100

    Simon,

    Thank you so much for you help! It works great! :)

    Thanks again,
    Carolyn
    ccnorris Guest

  4. #4

    Default 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

  5. #5

    Default 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

Similar Threads

  1. Finding nearest...
    By Strelok001 in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 1
    Last Post: June 10th, 09:40 PM
  2. Replies: 2
    Last Post: February 24th, 08:12 AM
  3. Snap Sprites to Nearest Grid Space
    By starrize webforumsuser@macromedia.com in forum Macromedia Director Lingo
    Replies: 2
    Last Post: October 30th, 05:36 AM
  4. Rounding Up
    By Brent Bortnick in forum ASP
    Replies: 14
    Last Post: October 8th, 04:19 AM
  5. Query, Join on nearest
    By Tommy in forum Microsoft SQL / MS SQL Server
    Replies: 5
    Last Post: July 10th, 08:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •