Search code examples
oracle-databaseoracle-apex

Oracle Apex Currency format mask remove decimal


I am currently using the format mask FML999G999G999G999G990D00 to display this format: $123,456,666.00

However i need to remove the decimal part and only show comma separated dollar format, i.e. $123,456,666

How can this be achieved?


Solution

  • Check the docs. The format model is just a string that you can modify. In the one you are using, the 'D00' means "The Decimal character - D" followed by 2 trailing zeroes 00. So if you remove the "D00" you'll end up with a value without decimals.

    select to_char(
       100
      ,'FML999G999G999G999G990D00'
    ) with_decimals
          ,to_char(
       100
      ,'FML999G999G999G999G990'
    ) without_decimals
      from dual;
    
    WITH_DECIMALS                     WITHOUT_DECIMALS              
    --------------------------------- ------------------------------
    $100.00                           $100