Number Formatting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Stang02GT
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    Number Formatting

    I am trying to get negative numbers to display as (1,23)

    the current format is as follows...

    Code:
    '9G990D00', 'NLS_NUMERIC_CHARACTERS = '',.''
    If I edit 9G990D00 to (9G990D00) would that do it?
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by Stang02GT
    I am trying to get negative numbers to display as (1,23)

    the current format is as follows...

    Code:
    '9G990D00', 'NLS_NUMERIC_CHARACTERS = '',.''
    If I edit 9G990D00 to (9G990D00) would that do it?
    The dirty thoughts going in my head right now yield
    [CODE=mysql]select replace (replace (to_char('-5000.8','9999.9 9PR'), '<', '('), '>', ')') from dual[/CODE]

    Comment

    • Stang02GT
      Recognized Expert Top Contributor
      • Jun 2007
      • 1206

      #3
      Originally posted by r035198x
      The dirty thoughts going in my head right now yield
      [CODE=mysql]select replace (replace (to_char('-5000.8','9999.9 9PR'), '<', '('), '>', ')') from dual[/CODE]

      That worked nicely. Thanks very much! :)

      Comment

      • amitpatel66
        Recognized Expert Top Contributor
        • Mar 2007
        • 2358

        #4
        Try this as well:

        [code=oracle]

        SELECT '('||TO_CHAR(-5000.8 * -1,'9999.99')||' )' FROM dual

        [/code]

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          Originally posted by amitpatel66
          Try this as well:

          [code=oracle]

          SELECT '('||TO_CHAR(-5000.8 * -1,'9999.99')||' )' FROM dual

          [/code]
          That would work only for negative numbers?

          Comment

          • amitpatel66
            Recognized Expert Top Contributor
            • Mar 2007
            • 2358

            #6
            Originally posted by r035198x
            That would work only for negative numbers?
            Yap. the OP wanted to display the negative numbers in that particular format.
            Btw, the best way would be:

            [code=oracle]

            SELECT '('||TO_CHAR(AB S(-5800.0),'9999.9 9')||')' from dual

            [/code]

            Comment

            • r035198x
              MVP
              • Sep 2006
              • 13225

              #7
              Originally posted by amitpatel66
              ..Btw, the best way would be:

              [code=oracle]

              SELECT '('||TO_CHAR(AB S(-5800.0),'9999.9 9')||')' from dual

              [/code]
              Not unless they have both negative and positive numbers and want to format their negative numbers that way.

              Comment

              Working...