Introduction

In this article, We will show 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 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:

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:

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


Back to Top