How to convert a string to a number Variable and store the decimal

Hello!

Here's my problem!

I get information from a source that I can't control.  He sends me the number in to form chains.

Ex: 12,200.49

I tried usingval() but only get '12' because it stops when she sees a comma or a period.

I also tried using Replace() to remove the comma and period, but then my increase, because the last two digits are now a part of the number and either behind a decimal point.

Some examples of code

< cfset price = "12,200.49" >

< cfoutput >
#val (Price) #.
< cfset price = ' #Replace (Price, ",", "","ALL") # ">

< BR / >
#val (Price) #.
< cfset price = "#Replace(Price,".","","ALL") #" >
< BR / >
#val (Price) #.

< cfset price = #NumberFormat (Price, "_. _") # >
< BR / >
FINISHED WITH #Price #.

< / cfoutput >

The output of the code above is as follows:

12
12200
1220049
FINISHED WITH 1220049.00

So, you can see that 12,200.49 is now 1,220,049.00 because the two numbers when added.

What I would like to end by is a string '12,200.49' which is now a number like this $12 200,49

Help, please!

Hello

Try this


   
   
#DollarFormat (price) #.

Tags: ColdFusion

Similar Questions

  • How to convert a string to a number?

    How to convert a numeric string to a number of TestStand?

    Use Val().

    Example Val (Locals.myString)

  • How to create impulses cause a pulse width Variable AND at the same time

    Hi all

    I have a NI PCI-6251 that comes with 2 counters, a FREQOUT port and then some DIO, DAC and ADC.  I want to trigger a pulse of variable width (easy to do with two counters) and a frequency closed, exit at the same time.  So, I want to end up with a line that will display TOP for some variable time, while the other exits a train of pulses for a time variable.  It is easy to do if you have 4 counters but I don't have one.  Does anyone have an idea to implement these two things AND making them trigger at the same time with the PCI-6251 card?

    The line is high for as long as your pulse train controlled?

    If so, set up the first counter as output pulse, configure the 2nd as output continuous meter but with the internal of the first counter output as its trigger to pause (pause when it is low).  Start the 2nd meter before the first.

    If not, you will need to use the digital output to replace at least one of the counters (max sampling rate is 10 MHz, so this would give less resolution compared to the time base of 80 MHz counters).  So you would simply write the waveform predetermined in the buffer and he clock at the desired rate and the number of samples to give the signal that you want.  You need to generate some other subsystem as FreqOut clock.

    Best regards

  • [Oracle 8i] How to convert a string (timestamp) in a date?

    I find it difficult to know how to convert a string to a date time stamp (or possibly several).

    The timestamp is 20 positions, character (NOT NULL, CHAR (20))
    in the format: YYYYMMDDHHMMSSUUUUUU
    where Y = year, M = month, D = day, M = Minutes, S = seconds and U = microseconds

    The reason why I want to convert it is so that I can compare a timestamp to each other (that is, I want to be able to find the MIN (timestamp), MAX (timestamp) and make comparisons of inequality).

    Is this possible?

    Thanks in advance for the help on this!

    Hello

    As Damorgan said, if all you want to do is find which is the earlier or later, then you can just compare the strings: they are in a format where it works.

    If you need to do other things, such as compare to today date or see the difference between two of your lines of days, you will need to convert it to date. (He has no reason to convert them to numbers).

    A new TIMESTAMP data type, which manages the fractions of a second, was introduced in Oracle 9.
    Since you use Oracle 8 (depending on your subject line), or it must be
    (1) ignores the microseconds, or
    (2) use a separate column for microseconds.

    Whatever it is, use TO_DATE to convert the first 14 characters in DATE:

    TO_DATE ( SUBSTR (txt, 1, 14)
            , 'YYYYMMDDHH24MISS'
            )
    

    where txt is your column of type CHAR.
    To convert microseconds to a number (between 0 and 999999):

    TO_NUMBER (SUBSTR (txt, 15))
    
  • How to convert a .fmb file to .xml file and also how to download apex?

    How to convert a .fmb file to .xml file and also how to download the .xml file converted in the oracle apex?

    Any idea?

    Any link?

    Published by: skud on February 24, 2011 21:17

    Published by: skud on February 24, 2011 21:28

    Hello

    You need to replace the scott.nature_of_trans by nature_of_trans and re he convert to xml, and then create.

    Kind regards

    Patel Kartik
    ------------------------------------------------------------------------
    http://patelkartik.blogspot.com/
    http://Apex.Oracle.com/pls/Apex/f?p=9904351712:1

  • How to acquire and store the values of DAQmx analog voltage (I do not want the graphic, but strings and values in a chart)?

    Hello

    How acquire and store the values of voltage DAQmx?

    I tried several code example, but they can't get the chart. I don't want to chart. I want to measure exactly the analog voltage values and record these values - as an excel chart, that contains the selected channels and voltage values.

    What the example code that I can use?

    My hardware is NI PCI-6251.

    Thank you very much.


  • I want to restrict a field to a positive number (dollars and cents) with decimal.

    I want to restrict a field to a positive number (dollars and cents) with decimal.  The maximum length of the field should be 15 characters, including decimals as 999999999999.99

    I need a script?

    Thank you

    Gaul.steve59

    Lol the Format of the field value number and you will be able to specify the interval of values (0 - 999999999999.99) in the validation tab.

  • How to create variables and store them?

    How to create variables and store them?

    As someone has already said, we need to learn a little more about what you want to do with these variables, but in general, APEX elements are probably what you want. You can create the elements APEX at the request or Page level. Once you define the value of an element, you can reference anywhere else in the application. So if you have an article on page 1 called P1_ENAME, you can reference it on page 32 using bind variables syntax: P1_ENAME. If you just want to store but not to display certain information, you can use either a hidden page element or an element of Application level. Take a look at day 2 Developers Guide for more information.

    Tyler

  • Converts a string to a number

    Hi all, I'm new to labview and I want to show a certain number (temp.) on a diagram. I get COM port as string data... How to convert this number to be used in the diagram or for reasons of comparison... Could you help?

    This is my block diagram:

    Fract/Exp function Number string

  • How to convert a string and use a rope as a property?

    I have an array in the following format:

    {ownsCar: 'true', ownsBike: 'true', ownsHouse: 'true'}

    {ownsCar: ownsBike 'false',: 'true', ownsHouse: 'true'}

    {ownsCar: 'true', ownsBike: ownsHouse 'false',: 'true'}

    etc ............

    And I need to test against each element, for example

    If...

    myDataGrid ["myItem"] .ownsCar is object (myCheckbox) .label

    ... then

    If...

    myDataGrid ["myItem"] .ownsBike is object (myCheckbox) .label

    ... then

    If...

    myDataGrid ["myItem"] .ownsHouse is object (myCheckbox) .label

    ... then

    But I have to build my application where the property (for example 'ownsCar', 'ownsBike', 'ownsHouse') is a variable such as:

    If...

    myDataGrid ["myItem"] .myProperty is object (myCheckbox) .label

    ... then

    I would like to browse my table, by counting the number of items and then use each element as a property.

    How to convert the string (for example, "ownsCar") in a property "myProperty"?

    Thanks in advance

    Chris

    OK, if I got this right what you need to do is introspection.

    The easiest way to do this would be:

    for ( var propertyName:String in myObject ) {
         // Do what you need with this here:
         myObject[ propertyName ];
    }
    
  • Please help, convert this string to a number format

    I send orders via RS232 to my machine and the machine sent back with a display of the number "40" in display normal in my image attatched. I tried to use the string conversion to digital tools, but there is nothing happen just '0 '.

    I wondered with it, then I try output string in a different way as in attached code, display and hex display and see the format of it.

    I want to get the string '40' to take the number, how can I get it? Help, please

    Thank you in advance.

    It has worked well for me. Just to be on the safe side, you can use the Trim function spaces (channels palette) to clear the characters "\".

    Steve

  • How to convert a string to byte array

    Hello

    I want to convert a string with a hexadecimal number in the array of bytes, this string includes a cutting-edge information, but I don't want to add this tip to arry bytes.

    detailed information please see the photo. I hope someone can give me some instructions, thank you very much.

    The accepted solution of Giedrius.S is not correct, based on the image shown in the first post. That the solution will not eliminate the spaces before the tip, and the string to byte array to convert individual characters '0', '8', 'space', '9', etc. for them to byte values. The right solution, based on the image below:

  • How to convert a string to a percentage?

    I'm new with Actionscript, but I do a Stress Test and I got to the point where I need to convert this final value (score) to a percentage. The maximum they can get is 35.

    scoreText is the name of the instance that I have used for their score which is a dynamic text

    I was thinking about something like that, but I could be totally wrong:

    function scoreToPercentage(evt:Event) {}

    var scoreText = Number (scoreText);

    var percent: Number = scoreText * 100;

    var roundedPercentage:Number = Math.round (percentage);

    var percentAsString:String = roundedPercentage + '% ';

    }

    Thanks for any help.

    Wait so much worse, I finally did!

    Here's the code I used:

    function updateScore(evt:Event) {}

    round var = Math.round(score / 35 * 100)/1

    scoreText.text = String (round + '%');

    }

    stage.addEventListener (Event.ENTER_FRAME, updateScore);

    I gave up and you just use an event listener. But thanks anyway for tons for the help!

  • Converting a string to a number

    Hello

    I have a problem to send a string to a number...

    I have a field of text called score0: -.

    var score = score0.text;

    Chain (score0.text) will be an 's' at the end time in seconds and tenths, so I will receive something in the sense of "8.1" s as the value...


    I would like to take score0.text, remove the 's' then * 1000 the amount that a certain number before using...

    Is this possible? Thanks for any help in advance...

    score: var number = parseFloat (score0.text) * 1000;

  • How to convert a string literal function function valid

    Hello

    I have a situation where I need to get the built-in (sysdate/sysdate-1/sysdate-2) as variables. As the variable is taken as a string, it is considered as a string, not a function. Is it possible to convert the string literal in valid function.

    Here is an example for better understanding. I used v_var to store the 'sysdate-1 "in the form of string literal. Try to change the value.


    */*-------------------------------------------------------------------------------------*/*
    declare

    v_var varchar2 (20): = ' sysdate-1';
    date of v_var2;

    Start

    Select v_var in the double v_var2;

    dbms_output.put_line ('v_var2: ' | v_var2);

    end;

    */*-------------------------------------------------------------------------------------*/*


    Thanks in advance

    Or

    SQL>  var str varchar2(20)
    SQL>  exec :str := 'sysdate - 1'
    PL/SQL procedure successfully completed.
    
    SQL>  select trim(dbms_xmlgen.getxmltype('select ' || :str || ' s from dual').extract('//text()')) str from dual
    /
    STR
    ------------------------
    15.07.09
    1 row selected.
    

Maybe you are looking for

  • Tungsten e2

    In the communications on my tungstene2 I can't access my bluetooth option. I get failure bluetooth message saying bluetooth missing components. Reinstall the software. I don't have the original cd. HELP please.

  • x 201 volume control buttons are not displayed in the volume levels

    the control buttons of the volume at the top of my thinkpad x 201 suddenly stopped displaying the volume level of the speakers. When the user presses the volume higher or lower keys. It has nothing to do with the volume control in the toolbar of the

  • HP ENVY printer 4520: Download the software keeps freezing

    Try to download the printing HP ENVY 4520 for installation on my MacBook software.Download keeps freezing. Not a wifi connection problem.

  • Stuck pixel white (Pavilion tx2520au)

    Hi, guys! I have this small pixel which is always in white on top of the screen. Is it possible to fix it without having to drive a long way to the local HQ of HP? Tried a couple of solutions online as the tap method, which did not work. ---------- H

  • How to bring back the Windows Media Player?

    I deleted the windows media player folder because he screwed up, and I thought that I would just install it again. I downloaded media player 10 and 11 on microsoft.com, and they both say that I can not install. I tried the windows update, but it will