获取每个季度第一天的日期
GBase社区管理员create function get_q_firstd(in_time date)
returning date;
define v_in_time date;
define cur_q int;
define rs_q_day date;
let v_in_time=in_time;
if v_in_time is not null then
select quarter(v_in_time) into cur_q from sysmaster:sysdual;
if cur_q = 1 then select year(sysdate)||"-01-01" into rs_q_day from sysmaster:sysdual;
elif cur_q = 2 then select year(sysdate)||"-04-01" into rs_q_day from sysmaster:sysdual;
elif cur_q = 3 then select year(sysdate)||"-07-01" into rs_q_day from sysmaster:sysdual;
elif cur_q = 4 then select year(sysdate)||"-10-01" into rs_q_day from sysmaster:sysdual;
else
exit;
end if;
else
select quarter(current) into cur_q from sysmaster:sysdual;
if cur_q = 1 then select year(sysdate)||"-01-01" into rs_q_day from sysmaster:sysdual;
elif cur_q = 2 then select year(sysdate)||"-04-01" into rs_q_day from sysmaster:sysdual;
elif cur_q = 3 then select year(sysdate)||"-07-01" into rs_q_day from sysmaster:sysdual;
elif cur_q = 4 then select year(sysdate)||"-10-01" into rs_q_day from sysmaster:sysdual;
else
exit;
end if;
end if;
return rs_q_day;
end function;
热门帖子
- 12025-12-01浏览数:182764
- 22023-05-09浏览数:25062
- 42023-09-25浏览数:18526
- 52020-05-11浏览数:17529