简体   繁体   中英

Remove Trailing Zeros when Casting to Money

How to remove the zeros

  select CONVERT(varchar, CAST( -3563338 AS money), 1)

Output

-3,563,338.00

Expected Output

-3,563,338

Use FORMAT :

SELECT FORMAT(-3563338,'#,###,##0')

-3,563,338

The money type output includes a decimal component for change. But, since you don't want to see that it might be easier to just use FORMAT instead.

请尝试以下-使用replace()函数

select replace(CONVERT(varchar, CAST( -3563338 AS money), 1),'.00','')

这将工作:

select TO_CHAR(-3563338.00,'99999999') from dual;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM