bestlong 怕失憶論壇

標題: PostgreSQL 將數字轉換成英文描述 [打印本頁]

作者: bestlong    時間: 2009-11-19 17:04     標題: PostgreSQL 將數字轉換成英文描述

在處理金額資訊有時都要將其轉換成文字描述,特別是貿易相關文件
以往都要自行寫程式組合,不過 PostgreSQL 本身就提供 cash_words() 函式來處理
以下列出幾個執行結果:

# select cash_words('1234567.89'::money);
One million two hundred thirty four thousand five hundred sixty seven dollars and eighty nine cents

# select cash_words('9876543.21'::money);
Nine million eight hundred seventy six thousand five hundred forty three dollars and twenty one cents

# select cash_words('109876543.21'::money);
One hundred and nine million eight hundred seventy six thousand five hundred forty three dollars and twenty one cents

# select cash_words('32109876543.21'::money);
Thirty two billion one hundred and nine million eight hundred seventy six thousand five hundred forty three dollars and twenty one cents

# select cash_words('321098765.4321'::money);
Three hundred twenty one million ninety eight thousand seven hundred sixty five dollars and forty three cents




歡迎光臨 bestlong 怕失憶論壇 (http://www.bestlong.idv.tw/) Powered by Discuz! X1.5