数字金额转换成中文金额(数据库实现)

原创 2006年05月26日 13:38:00

利用函数实现,以Sql server2000为基础实现。 利用函数实现,以Sql server2000为基础实现。

Create     FUNCTION UF_FormatDecimalToChinese (@ConvertValue numeric(15,2)) 
RETURNS VARCHAR(200) AS

BEGIN
Declare @LowString  VARCHAR(200) 
Declare @UpString   VARCHAR(200)
Declare @UpPart     VARCHAR(200)
Declare @i          int

Set @LowString  = LTRIM(RTRIM(ROUND(@ConvertValue,2)))
Set @i = 1
Set @UpString   = ''

While ( @i <= len(@LowString))
Begin
      Select @UpPart = case substring(@LowString,len(@LowString) - @i + 1,1)
                            WHEN  '.' THEN  '元'
                            WHEN  '0' THEN  '零'
                            WHEN  '1' THEN  '壹'
                            WHEN  '2' THEN  '贰'
                            WHEN  '3' THEN  '叁'
                            WHEN  '4' THEN  '肆'
                            WHEN  '5' THEN  '伍'
                            WHEN  '6' THEN  '陆'
                            WHEN  '7' THEN  '柒'
                            WHEN  '8' THEN  '捌'
                            WHEN  '9' THEN  '玖'
                            END
                          +
                            case @i
                            WHEN  1   THEN  '分'
                            WHEN  2   THEN  '角'
                            WHEN  3   THEN  ''
                            WHEN  4   THEN  ''
                            WHEN  5   THEN  '拾'
                            WHEN  6   THEN  '佰'
                            WHEN  7   THEN  '仟'
                            WHEN  8   THEN  '万'
                            WHEN  9   THEN  '拾'
                            WHEN  10  THEN  '佰'
                            WHEN  11  THEN  '仟'
                            WHEN  12  THEN  '亿'
                            WHEN  13  THEN  '拾'
                            WHEN  14  THEN  '佰'
                            WHEN  15  THEN  '仟'
                            WHEN  16  THEN  '万'
                            ELSE ''
                            END
    Set @UpString = @UpPart + @UpString
    Set @i = @i + 1
End


Set @UpString = REPLACE(@UpString,'零拾','零')
Set @UpString = REPLACE(@UpString,'零佰','零')
Set @UpString = REPLACE(@UpString,'零仟','零')
Set @UpString = REPLACE(@UpString,'零零零','零')
Set @UpString = REPLACE(@UpString,'零零','零')
Set @UpString = REPLACE(@UpString,'零角零分','整')
Set @UpString = REPLACE(@UpString,'零分','整')
Set @UpString = REPLACE(@UpString,'零角','零')

Set @UpString = REPLACE(@UpString,'零亿零万零元','亿元')
Set @UpString = REPLACE(@UpString,'亿零万零元','亿元')
Set @UpString = REPLACE(@UpString,'零亿零万','亿')
Set @UpString = REPLACE(@UpString,'零万零元','万元')
Set @UpString = REPLACE(@UpString,'万零元','万元')
Set @UpString = REPLACE(@UpString,'零亿','亿')
Set @UpString = REPLACE(@UpString,'零万','万')
Set @UpString = REPLACE(@UpString,'零元','元')
Set @UpString = REPLACE(@UpString,'零零','零')


If ( '元' = substring(@UpString,1,1))
    Set @UpString = substring(@UpString,2,(len(@UpString) - 1))

If ( '零' = substring(@UpString,1,1))
    Set @UpString = substring(@UpString,2,(len(@UpString) - 1))


If ( '角' = substring(@UpString,1,1))
    Set @UpString = substring(@UpString,2,(len(@UpString) - 1))

If ( '分' = substring(@UpString,1,1))
    Set @UpString = substring(@UpString,2,(len(@UpString) - 1))

If ( '整' = substring(@UpString,1,1))
    Set @UpString = '零元整'


Return  @UpString

END


金额从数字转换成中文汉字大写的实现

以下简单封装的实现方法,详细见注释class money2chinese { private $amount; // 金额 private $num2chinese; // 大写数字 ...

讲金额(数字)转换成中文大写

001 package com.phyl.util; 002 import java.util.HashMap; ...

将数字转换成中文金额的大写形式

package com.unteck.fms.web.businessdata.controller; import org.springframework.beans.factory.anno...

js 数字金额大小写转换成中文大写

function Arabia_to_Chinese(Num) { for(i=Num.length-1;i>=0;i--) { Num = Num.replace(",","")//替换to...

黑马程序员——金额转换,阿拉伯数字转换成中文大写

package com.heima.problemA; import java.util.ArrayList; import java.util.List; /* * 思路: 待转换的整数分为...

java练习:金额转换,阿拉伯数字转换成中文传统形式

import java.util.Scanner; public class Test2 { public static void main(String[] args) { // TOD...
  • fmi110
  • fmi110
  • 2015年09月05日 12:39
  • 1572

转换成中文大写金额

  • 2011年09月14日 15:32
  • 3KB
  • 下载

PHP把金额数字转换成大写形式

function getChineseNumber($num){ $d = array('零','壹','贰','叁','肆','伍','陆','柒','捌','玖'); $e = array...

数字金额转换成汉字

import java.util.Arrays;public class Num {private String[] hanArr= {"零","壹","贰","叁","肆","伍","陆","柒",...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:数字金额转换成中文金额(数据库实现)
举报原因:
原因补充:

(最多只允许输入30个字)