Login     Register

        Contact Us     Search

XLeratorDB/strings Online Documentation

SQL Server DOLLAR function


DOLLAR

Updated: 30 April 2009

Use DOLLAR to convert a number to text using currency format, with the decimals rounded to the specified place.
 Syntax
SELECT [wctString].[wct].[DOLLAR] (
   <@Number, float,>
 ,<@Decimals, int,>)
Arguments
@Number
the number to be evaluated. The @Number argument can be an expression of types that are implicitly convertible to float.
 
@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.
 
Return Types
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
-------------------------------------------------------------------------------
$1,000,000.00
 
(1 row(s) affected)
 


Select
wct.DOLLAR(-1000000,2)
 
This produces the following result
-------------------------------------------------------------------------------
($1,000,000.00)
 
(1 row(s) affected)
 


Select
wct.TEXT(-1000000,'$#,##0.00;($#,##0.00)')
 
This produces the following result
-------------------------------------------------------------------------------
($1,000,000.00)
 

(1 row(s) affected)



Copyright 2008-2024 Westclintech LLC         Privacy Policy        Terms of Service