Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favourite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved in your SSC briefcase from the favorites tab.
Download now (direct download link)

Converting money to the word value.

By James Travis,

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".

Total article views: 407 | Views in the last 30 days: 4
 
Related Articles
FORUM

$123 --> One Hundred Twenty-three ...

Does anyone have any script or know a way that I can convert $amount to words, as written on a check...

SCRIPT

fnArabToEnglish(from Arabian number to english)

This function can convert a Arabian number to english,for example,if you input 1234.56, then you'll ...

BLOG

Book Review: The Billion Dollar Game

The Billion Dollar Game: Behind the Scenes of the Greatest Day In American Sport – Super Bowl Sunday...

FORUM

Historical Dollars

Comments posted to this topic are about the item [B]Historical Dollars[/B] I wouldn't put a salary h...

FORUM

Expected output

Expected output

Tags
miscellaneous    
t-sql    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones