T-SQL - Display Decimal Numbers As Money

In this article, we will see how to

  • Display Decimal Numbers as Money with cents.
  • Display Decimal Numbers as Money without cents.
Scenario

I have a decimal number like 541777367.100000. I need to display it in money format as in the following:

  • With cents to be like this 541,777,367.10.
  • Without cents to be like this 541,777,367.
Display Decimal Numbers as Money with Cents

To display decimal numbers as money with cents, you can simply cast the number to money as the following.

  1. SELECT convert(varchar,cast(541777367.100000 as money), 1) as 'Budget' 

[Output]



Display decimal numbers as money without cents

To display decimal numbers to money with cents, it will require replacing the cents digit as the following:

  1. SELECT replace(convert(varchar,cast(floor(541777367.100000) as money),1), '.00'''as 'Budget' 

[Output] 



Applies To

  • SQL Server 2017
  • SQL Server 2016
  • SQL Server 2014
  • SQL Server 2012
  • SQL Server 2008
  • SQL Server 2005
Conclusion

In this article, we have learned how to

  • Display Decimal Numbers as Money with cents.
  • Display Decimal Numbers as Money without cents.
References


Similar Articles