Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trim trailing zeroes
Message
De
25/10/2013 15:54:06
 
 
À
25/10/2013 15:27:56
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01586185
Message ID:
01586406
Vues:
51
>>>>I'm embarrassed to ask this:
>>>>
>>>>I can't figure out how to display a numeric value with the trailing zeroes trimmed. So, if the value is stored in the table as 88.99000, I want the value to display in a report as 88.99.
>>>>
>>>>Thanks,
>>>>
>>>>Yossi
>>>
>>>One possibility
>>>
>>>
>>>alltrim(transform(value), 1, '0') && this will remove trailing zeros but will make this character value
>>
>>Whoops! Your solution trims significant zeroes as well in say, 890 becomes 89.
>>
>>How about this solution:
>>
>>
>>? IIF(AT('.', TRANSFORM(cc)) > 0, alltrim(transform(cc), 1, '0'), TRANSFORM(cc))
>>
>
>Why don't you do it the correct way?
>
Set decimals to 2
That's the right answer to the wrong question. It turns out the OP has an actual use case for trimming excess zeroes to the right of the decimal point. SET DECIMALS TO 2 works only if there are exactly 2 significant non-zero digits to the right of the decimal point.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform