CMChalcraft
asked on
How do I get a numeric field to output to only 2 decimal points
How do I get a numeric field to output to only 2 decimal points, such as 4235.98? With Net being the value field that current outputs 64.3232697. I only want 64.32 to be the result.
SELECT ID, HOMENAME, Net
SELECT ID, HOMENAME, Net
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i agree with the above.
if you don't want to round, but floor/ceil instead, you will need to *100 and /100 in betwee.
if you don't want to round, but floor/ceil instead, you will need to *100 and /100 in betwee.
Another idea would be to convert to an int price in pence/cent/whatever and fill in the decimal place at the frontend again. The advantage being you transfer only exact int values. On the other hand there is the currency type for a reason.
Bye, Olaf.
Bye, Olaf.
ASKER
Thanks for rapid help. I will llok at Olaf suggests when I have more time. Have used Russ's solution as quicker to implement.
Regards
Chris C
Regards
Chris C
SELECT ID, HOMENAME, CAST(Net as numeric(19,2)) as Net
FROM whatever
The 19 number is the total number of digits, and can be decreased to best represent the values in that column to minimize the size needed to store them. (see 'Storage Bytes')