DOLLAR
Updated 2023-11-10 14:44:04.823000
Syntax
SELECT [westclintech].[wct].[DOLLAR] (
<@Number, float,>
,<@Decimals, int,>)
Description
Use the scalar function DOLLAR to convert a number to text using currency format, with the decimals rounded to the specified place.
Arguments
@Decimals
is the number of decimal places in the result. The @Decimals argument can be an expression of types that are implicitly convertible to int.
@Number
the number to be evaluated. The @Number argument can be an expression of types that are implicitly convertible to float.
Return Type
nvarchar(4000)
Remarks
DOLLAR returns the same results as TEXT(@Number, '$#,##0.00;($#,##0.00)').
To format a number using other grammalogues (€, £, ¥) consider using the TEXT function.
Examples
Select wct.DOLLAR(1000000, 2);
This produces the following result.
{"columns":[{"field":"column 1"}],"rows":[{"column 1":"$1,000,000.00"}]}
Select wct.DOLLAR(-1000000, 2);
This produces the following result.
{"columns":[{"field":"column 1"}],"rows":[{"column 1":"($1,000,000.00)"}]}
Select wct.TEXT(-1000000, '$#,##0.00;($#,##0.00)');
This produces the following result.
{"columns":[{"field":"column 1"}],"rows":[{"column 1":"($1,000,000.00)"}]}