Skip to Content
author's profile photo
Former Member

How to format a string which is representing an amount

Hi Experts,

My question is : Do we have any function which can correctly format an string which is storing an amount.

For example:

Input String : '1234567'

Expected outpt : '1.234.456,00'

Input String : '1.23456.78,2586'

Expected outpt : '12.345.678,26'

Requirement is like :

there should be exectly 3 digits between consecutive '.' ','

if there are more then 2 digits after decimal point , the number should be rounded off.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Posted on Aug 21, 2007 at 11:02 AM

    You can use CONVERT_STRING_TO_INTEGER

    But the entry doesn't have to have any comma or point.

    For your case you can:

    1- Split string between integer and decimal part.

    2. Delete all point from integer part

    3. Convert to integer

    4. Check if third char of decimal part is greater than 5. If it is add 1 to second char.

    5. Concatenate integer from step three, a comma and first two chars from step 4.

    If u don't know how program any step post here.

    Regards and remember reward all helpfull answes.

    manel

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hmmm that's correct. we can do that, that way. but i did not want to hard code

      the decimal point to ","

      otherwise application wont work as expected, if the same application is used in

      American context ( as in US, people use "." as decimal point) .

      Is there any way to find out the context , in which the application is being used ?

      Thanks and Regards

      Shiv