大家好,小编来为大家解答以下问题,python输入出生年份,输出年龄,怎么用python输入姓名和年份,现在让我们一起来看看吧!

create or replace function F_GET_NL_BY_CSRQ(csrq date, v_date date)
return number
/*
* 根据出生日期和日期,计算当时的年龄
*/
as
v_yr1 char(4);
v_yr2 char(4);
begin
begin
v_yr1 := to_char(v_date,'mmdd');
if csrq is not null then
v_yr2 := to_char(csrq,'mmdd');
if v_yr2<=v_yr1 then
return to_number(to_char(v_date,'yyyy'))-to_number(to_char(csrq,'yyyy'));
else
return to_number(to_char(v_date,'yyyy'))-to_number(to_char(csrq,'yyyy'))-1;
end if;
else
return null;
end if;
exception
when others then
return null;
end;
end;
本文介绍了如何在Python中编写一个名为F_GET_NL_BY_CSRQ的函数,用于根据输入的出生日期(CSRQ)和当前日期(v_date),计算并返回用户的年龄。函数使用OracleSQL的逻辑处理日期,包括异常处理。
3177

被折叠的 条评论
为什么被折叠?



