Tuesday, September 2, 2014

Formatting numbers

What is a datatype of that number? Is it a float?


Before a numeric value (date, or any non-textual value) is displayed, it must be converted to characters by the application that displays it (e.g. SQL Server Management Studio or your web app), and there the format kicks-in.


Resulting format depends on a data type. Try CAST to money, decimal(x,y) or even varchar.


CONVERT also has third parameter that affects how number will be displayed, also influenced by a datatype.


The application you use to display the value also probably has some "format" property or option that would enable you desired format.


If everything fails, you can always convert to varchar, format it manually with "brute force" and send varchars out. But you will not be able to calculate with it, create sums etc.


No comments:

Post a Comment