SQL Server Central is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 

Converting money to the word value.

By James Travis, 2002/04/11

Total article views: 338 | Views in the last 30 days: 2

With this script you can supply an money value such as $12525.83 and it will return the word value "Twelve Thousand Five Hundred And Twenty-Five Dollars And Eighty-Three Cents".
It is comprised of a table for Number to Name and a procedure to parse into it's pieces
NOTE: This only goes to billions at this point, but easy enough to expand.
May work even better as a function in 2000.


Update Notice: If you tried this code before April 17, 2002 the following bug fixes have been made.

.00 throwing error has been fixed.
20.00 displaying "Twenty-Dollars" now corrrectly diplays "Twenty Dollars".
111111.25 Not showing values for Thousands, Millions, Billions with a 1 in the Tens place corrected.
Corrected single ones position for each place all doing single digits amount for place as double that same number, for example 2000 was outputting Twenty-Two Thousand.
Got rid of second "and" in output when there is cents so instead of 250.12 being "Two Hundred And Fifty Dollars And Twelve Cents" now outputs "Two Hundred Fifty Dollars And Twelve Cents" unless is 250 then is "Two Hundred And Fifty Dollars".

By James Travis, 2002/04/11

Total article views: 338 | Views in the last 30 days: 2
Your response
 
 
Related tags

Miscellaneous    
T-SQL Aids    
 
Like this? Try these...
Already registered?  

Free registration required

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Register

E-mail address:
Password:
Password (confirm):

  

Subscriptions

We ask you to register on the site and subscribe to our newsletters. Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

We ask that you give the newsletter a try for a week. Over 200,000 SQL Server Professionals a day find it entertaining and useful. If not, you are welcome to unsubscribe at anytime.

Steve Jones
Editor, SQLServerCentral.com