|
|
Cooperative Extension Service |
|
|
|
||
|
|
||
|
Agricultural
Experiment Station |
||
|
|
|
|
Here's a trick from Jayne Albino on how to turn a numeric value, such as 54334, into an alphabetic value, such as FIFTY-FOUR THOUSAND THREE HUNDRED THIRTY-FOUR. To do this, use the SP date format to spell out the number after converting the number to a date (using julian conversion):
select to_char(to_date(54334,'J'),'JSP') from dual; -- For upper-case letters
select to_char(to_date(54334,'J'),'JsP') from dual; -- For mixed-case letters
select to_char(to_date(54334,'J'),'jSP') from dual; -- For lower-case letters
The minimum julian number allowed is 1, and, the maximum julian number allowed is 5373484, so, if you want to make a check out for a larger amount, just send it to me! Also, this only works for integer amounts. If you want dollars and cents, you'll have to split up the amount into it's integer and decimal parts, and handle the case of a zero amount, such as in:
select decode(trunc(54334.69),0,'ZERO',to_char(to_date(trunc(54334.69),'J'),'JSP'))
|| ' DOLLARS AND ' || decode(trunc(mod(54334.69,1)*100),0,'ZERO',
to_char(to_date(trunc(mod(54334.69,1)*100),'J'),'JSP')) || ' CENTS'
from dual;
Or, to make it general, using a variable amount (you'll have to do an "undefine amount" afterwards if you want to try out other values):
select decode(trunc(&&amount),0,'ZERO',to_char(to_date(trunc(&&amount),'J'),'JSP'))
|| ' DOLLARS AND ' || decode(trunc(mod(&&amount,1)*100),0,'ZERO',
to_char(to_date(trunc(mod(&&amount,1)*100),'J'),'JSP')) || ' CENTS'
from dual;
This Page was Last Updated on 06/04/07
You Are Visitor Number |
|
|
© 2006 |
|
|
University of Arkansas • Division of Agriculture |
Mission
•
Disclaimer
•
EEO
•
|