Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Transform number to string in dollar format
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00961098
Message ID:
00961173
Vues:
5
Mike,

Sorry, didn't notice that it's SQL Server forum. :) Anyway, it's much easier to do formatting in VFP becase T-SQL isn't very good at it.
Here's a sample T-SQL code you can run AS IS to see if it suits you and than adjust for your requirements.
DECLARE @FromValue int, @ToValue int
SELECT @FromValue = 1000, @ToValue = 25000
SELECT 
	REPLACE('$' + CONVERT( varchar(32), CONVERT(money, @FromValue), 1), '.00', '')
	+ ' - ' +
	REPLACE('$' + CONVERT( varchar(32), CONVERT(money, @ToValue), 1), '.00', '')
>Serge - I'm looking for SPT syntax, not VFP... I cannot find "Transform" or PADR in the SQL books!
>
>>
>>Try
 PADR(TRANSFORM(FromValue, "@$ 999,999") + " - " + ;
>>         TRANSFORM(ToValue, "@$ 999,999"),32) AS DisplayValue,
>>>I'm having trouble finding the syntax to return a dollar-formatted string (commas, dollar sign) from an integer value.
>>>
>>>What I have now is:
>>>SELECT STR(FromValue) + ' - ' + STR(ToValue) AS DisplayValue, STR(AssetsCode,2,0) AS cValue...
>>>
>>>which returns a 'displayvalue' of "1000 - 25000"
>>>
>>>But I want it to return "$1,000 - $25,000"
>>>
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform