Professional Web Applications Themes

Money data type - Microsoft SQL / MS SQL Server

Hello, How would I format a "Money" data type so that it displays two decimal places? I have a Money type field, but when the data is displayd on the web page it cuts out the second decimal digit if the digit is a zero. For instance 2.50 is displayed as 2.5. I was under the impression that the "Money" field took care of this for you, but apparently I need to do some formatting. By the way I'm using ASP/SQL...

  1. #1

    Default Money data type

    Hello,

    How would I format a "Money" data type so that it displays two decimal
    places?

    I have a Money type field, but when the data is displayd on the web page it
    cuts out the second decimal digit if the digit is a zero. For instance 2.50
    is displayed as 2.5. I was under the impression that the "Money" field took
    care of this for you, but apparently I need to do some formatting.

    By the way I'm using ASP/SQL


    sympatico Guest

  2. #2

    Default Re: Money data type

    Hi

    You could use the convert function to change it to a character datatype:

    From the subject "CAST and CONVERT" in Books Online:

    In the following table, the column on the left represents the style value
    for money or smallmoney conversion to character data.

    Value Output
    0 (default) No commas every three digits to the left of the decimal
    point, and two digits to the right of the decimal point; for example,
    4235.98.
    1 Commas every three digits to the left of the decimal point, and two
    digits to the right of the decimal point; for example, 3,510.92.
    2 No commas every three digits to the left of the decimal point, and
    four digits to the right of the decimal point; for example, 4235.9819.

    John

    "sympatico" <com> wrote in message
    news:9ZcZa.5774$bellglobal.com... 
    it 
    2.50 
    took 


    John Guest

  3. #3

    Default Money data type

    I have a database that uses the money data type a lot. Well, it is
    causing problems because it goes out to 4 decimal places $32.1234 - and
    I don't know what a tenth or hundreth cent piece looks like.

    So

    I want all money fields to be changed and only be 2 decimal places. I
    did an alter table:

    ALTER TABLE GLHistory ALTER COLUMN ghst_amount decimal(18,2)

    and received an error:

    The object 'DF__GLHistory__ghst___7FEAFD3E' is dependent on column
    'ghst_amount'.

    I don't have a clue what that object is (all of my objects start with v,
    r, t, p, or f, and no DF's).

    Does anyone have any suggesstions.

    Thanks in advance.

    Darin

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Darin Guest

  4. #4

    Default Re: Money data type

    Displaying the dependecies shows 5 view, 2 stored procedures, and 1 user
    defined function that rely on the GLHistory file.

    But, what do I have to do to change the ghst_amount from a money
    datatype to a decimal(18,2)?

    Darin

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Darin Guest

Similar Threads

  1. Converting from data type varchar to data type money
    By schaudry in forum Coldfusion - Advanced Techniques
    Replies: 6
    Last Post: June 10th, 11:01 PM
  2. Converting data type varchar to data type money
    By schaudry in forum Coldfusion - Getting Started
    Replies: 1
    Last Post: June 10th, 07:22 PM
  3. Replies: 3
    Last Post: October 18th, 06:56 AM
  4. Replies: 2
    Last Post: October 16th, 08:29 AM
  5. Which data type decimal, money, float...?
    By JCardinal in forum Microsoft SQL / MS SQL Server
    Replies: 2
    Last Post: August 6th, 04:18 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139