300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > mysql 计算农历_MySQL 获取农历年函数

mysql 计算农历_MySQL 获取农历年函数

时间:2021-06-25 05:49:33

相关推荐

mysql 计算农历_MySQL 获取农历年函数

begin

declare temp_num int;

declare chn_str varchar(10);

declare num_strvarchar(20);

declare res_year varchar(20);

declare iint;

declare jint;

set chn_str = '〇一二三四五六七八九';

set temp_num = num + 0;

set i = 1;

set res_year = '';

if temp_num >1000 or (temp_num > 0 and temp_num < 10) then

set num_str = temp_num;

begin

while i <= length(num_str) do

set j = substring(num_str from i for 1)+1;

set res_year = concat(res_year,substring(chn_str from j for 1));

set i = i+1;

end while;

end;

end if;

if temp_num = 10 then

set num_str = temp_num;

set res_year = '十';

end if;

if temp_num > 10 and temp_num < 20 then

set num_str = temp_num;

set j = substring(num_str from 2 for 1)+1;

set res_year = concat('十',substring(chn_str from j for 1));

end if;

if temp_num = 20 then

set num_str = temp_num;

set res_year = '二十';

end if;

if temp_num > 20 and temp_num < 30 then

set num_str = temp_num;

set j = substring(num_str from 2 for 1)+1;

set res_year = concat('二十',substring(chn_str from j for 1));

end if;

if temp_num = 30 then

set num_str = temp_num;

set res_year = '三十';

end if;

if temp_num = 31 then

set num_str = temp_num;

set j = substring(num_str from 2 for 1)+1;

set res_year = concat('三十',substring(chn_str from j for 1));

end if;

return res_year;

end

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。