How do I display a calculated negative number with a minus sign?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tetsuo2030
    New Member
    • Apr 2010
    • 31

    How do I display a calculated negative number with a minus sign?

    Greetings all:

    I have a query like:
    Code:
    "Select myTable.WasCost
       , myTable.IsCost
       , [WasCost]-[IsCost] 
          AS myDifference 
    FROM myTable;"
    WasCost and IsCost are both set to Currency in myTable. If the myDifference comes out negative, it looks like ($100.00). User requests that it display as -$100.00 instead.

    I believe one can change the currency formatting in the table, but the Microsoft article on Formatting says the stored value for negative numbers is -$X.XX andthe display is ($X.XX). Also, since this is a calculated field, if I could make it work in the tables, would the query translate accordingly?
    Last edited by zmbd; Oct 3 '13, 03:28 PM. Reason: [z{placed code tags and stepped SQL}]
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    Specify how data displays by using custom formatting (ACC2007/2010)
    Has all of the details.

    Also please use the [CODE/] format for all SQL/Code/Formatted text. (^-^)

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #3
      Try the following to force the requested Format:
      Code:
      SELECT myTable.WasCost, myTable.IsCost, 
      Format([WasCost]-[IsCost],"$#,###.00") AS myDifference
      FROM myTable;

      Comment

      Working...