首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 .NET Java 游戏 视频 人才 外包 培训 数据库 书店 程序员
中国软件网
欢迎您:游客 | 登录 注册 帮助
  • 支票上需要把日期转换成大写,改怎么? [已结贴,结贴人:xuangxing]
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-11 17:11:58 楼主
    支票上需要把日期转换成大写,改怎么?

    具体要求如下:

    一至九月要写为:零壹、零贰、零叁、零肆、零伍、 
    零陆、零柒、零捌、零玖 
    十至十二月写为:壹拾月、壹拾壹月、壹拾贰月 
    日子照此办理比如2005年8月3日 
    应写为:贰零零伍年零捌月零叁日 
    2005年11月22日 
    应写为:二零零伍年壹拾壹月贰拾贰日

    比如函数名为:date_change();

    date_change('2005-11-22')--返回结果:二零零伍-壹拾壹-贰拾贰
    20  修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-11 19:05:501楼 得分:0
    怎么没人回复?在线等
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-11 20:24:592楼 得分:0
    SQL> create or replace function date_change(in_date in date)
      2        return varchar2 is
      3      v_date varchar2(30);
      4  begin
      5      v_date := to_char(in_date,'yyyy-mm-dd');
      6      v_date := translate(v_date,'0123456789-','零壹贰叁肆伍陆柒捌玖-');
      7      --v_date := replace(v_date,'0','零');
      8      return v_date;
      9  end;
    10  /

    函数已创建。

    SQL> select date_change(sysdate) from dual;

    DATE_CHANGE(SYSDATE)
    --------------------------------------------------------------------------------
    贰零零捌-零伍-壹壹

    SQL>
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-12 01:13:013楼 得分:0
    月为1.2.10的,日为1-9和10.20.30的,应在其前面加零,日为10-19的应在前面加壹。

    10月10日应该写为零壹拾月零壹拾日,如果写成壹拾月壹拾日就可以改成壹拾壹月或壹拾贰月,壹拾日后面可改的日期就更多。
    支票日期填写必须使用大写的中文字,要求是写完后前面和后面都不能再加字,如果前后还能加字的,前面就得加个零字。
    比如壹月、贰月,前面如果不加零,就可能被人改成“壹拾”壹月或“壹拾”贰月。月份如此,日期也如此。只不过日前面加零的情况更多,1-9日前面都可以加1或2,1前面还可以加3。
    记住前面不能加字,加字就不通时,就可以不加零。
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-12 09:04:184楼 得分:0
    sf
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-12 12:04:495楼 得分:0
    这个可以解决你的问题:
    有什么问题再说。
    --------------------------------------
    create or replace function date_change(
        v_src          in varchar2,
        v_date_format  in varchar2 default 'yyyy-mm-dd'
    )return varchar2 is
        v_result        varchar2(200);
        v_year          varchar2(4) default '';
        v_month        varchar2(4) default '';
        v_day          varchar2(4) default '';
        v_result_year  varchar2(20) default '';
        v_result_month  varchar2(20) default '';
        v_result_day    varchar2(20) default '';
    begin
        v_year  := to_char(to_date(v_src,v_date_format),'yyyy');
        v_month := to_char(to_date(v_src,v_date_format),'mm');
        v_day  := to_char(to_date(v_src,v_date_format),'dd');
       
        v_result_year := translate(v_year,'0123456789','零壹贰叁肆伍陆柒捌玖');
        if v_month < 10 then
            v_result_month := translate(v_month,'0123456789','零壹贰叁肆伍陆柒捌玖');
        else
            v_result_month := translate(substr(v_month,1,1),'0123456789','零壹贰叁肆伍陆柒捌玖') ¦ ¦ '拾';
            v_result_month := v_result_month ¦ ¦ translate(substr(v_month,2,1),'0123456789','零壹贰叁肆伍陆柒捌玖');
            if (v_month mod 10) = 0 then
                v_result_month :=  '零' ¦ ¦ v_result_month;
            end if;
        end if;
        if v_day < 10 then
            v_result_day := translate(v_day,'0123456789','零壹贰叁肆伍陆柒捌玖');
        else
            v_result_day := translate(substr(v_day,1,1),'0123456789','零壹贰叁肆伍陆柒捌玖') ¦ ¦ '拾';
            v_result_day := v_result_day ¦ ¦ translate(substr(v_day,2,1),'0123456789','零壹贰叁肆伍陆柒捌玖');
            v_result_day := RTrim(v_result_day,'零');
            if (v_day mod 10) = 0 then
                v_result_day := '零' ¦ ¦v_result_day;
            end if;
        end if;
        v_result := v_result_year ¦ ¦ '-' ¦ ¦ v_result_month ¦ ¦ '-' ¦ ¦ v_result_day;
        return(v_result);
    end date_change;
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-12 14:16:356楼 得分:0
    SELECT translate('2005年11月22日','0123456789','零壹贰叁肆伍陆柒捌玖') FROM dual
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-12 18:18:417楼 得分:0
    学习
    !!
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-14 13:14:218楼 得分:0
    SQL code
    select date_change('2008-10-10') from dual


    返回的结果为:贰零零捌-零壹拾零-零壹拾

    正确的结果应为:贰零零捌-零壹拾-零壹拾
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-14 13:21:379楼 得分:20
    Sorry,写少一个,
    这个你再试验一下。

    SQL code
    create or replace function date_change( v_src in varchar2, v_date_format in varchar2 default 'yyyy-mm-dd' )return varchar2 is v_result varchar2(200); v_year varchar2(4) default ''; v_month varchar2(4) default ''; v_day varchar2(4) default ''; v_result_year varchar2(20) default ''; v_result_month varchar2(20) default ''; v_result_day varchar2(20) default ''; begin v_year := to_char(to_date(v_src,v_date_format),'yyyy'); v_month := to_char(to_date(v_src,v_date_format),'mm'); v_day := to_char(to_date(v_src,v_date_format),'dd'); v_result_year := translate(v_year,'0123456789','零壹贰叁肆伍陆柒捌玖'); if v_month < 10 then v_result_month := translate(v_month,'0123456789','零壹贰叁肆伍陆柒捌玖'); else v_result_month := translate(substr(v_month,1,1),'0123456789','零壹贰叁肆伍陆柒捌玖') ¦ ¦ ''; v_result_month := v_result_month ¦ ¦ translate(substr(v_month,2,1),'0123456789','零壹贰叁肆伍陆柒捌玖'); if (v_month mod 10) = 0 then v_result_month := '' ¦ ¦ RTrim(v_result_month,''); end if; end if; if v_day < 10 then v_result_day := translate(v_day,'0123456789','零壹贰叁肆伍陆柒捌玖'); else v_result_day := translate(substr(v_day,1,1),'0123456789','零壹贰叁肆伍陆柒捌玖') ¦ ¦ ''; v_result_day := v_result_day ¦ ¦ translate(substr(v_day,2,1),'0123456789','零壹贰叁肆伍陆柒捌玖'); v_result_day := RTrim(v_result_day,''); if (v_day mod 10) = 0 then v_result_day := '' ¦ ¦v_result_day; end if; end if; v_result := v_result_year ¦ ¦ '-' ¦ ¦ v_result_month ¦ ¦ '-' ¦ ¦ v_result_day; return(v_result); end date_change;
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-14 14:07:0910楼 得分:0
    可以否?
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-17 10:31:5811楼 得分:0
    OK
    修改 删除 举报 引用 回复

    网站简介广告服务网站地图帮助联系方式诚聘英才English 问题报告
    北京创新乐知广告有限公司 版权所有 京 ICP 证 070598 号
    世纪乐知(北京)网络技术有限公司 提供技术支持
    Copyright © 2000-2008, CSDN.NET, All Rights Reserved