GBase 8s
运维管理
文章
取两个时间差之间的天数
GBase社区管理员发表于2023-05-12 09:25:21245次浏览0个评论
#结果如果差的天数为整,则直接获取;如果是差值之间的天数后面还有时分秒则,天数加1
CREATE function fn_dev_datetime(date1 datetime year to second,date2 datetime year to second)
returning integer;
DEFINE out_day INTEGER;
DEFINE t_day INTEGER;
DEFINE t_hour INTEGER;
DEFINE t_minute INTEGER;
DEFINE t_second INTEGER;
DEFINE t_sum INTEGER;
LET t_day = to_number(substr(date1 - date2,1,9));
LET t_hour = to_number(substr(date1 - date2,11,2));
LET t_minute = to_number(substr(date1 - date2,14,2));
LET t_second = to_number(substr(date1 - date2,17,2));
LET t_sum = t_hour + t_minute + t_second;
if t_sum > 0 then
LET out_day = t_day+1;
else
LET out_day = t_day;
end if;
RETURN out_day;
end function;
评论已关闭
热门帖子
- 12025-12-01浏览数:182759
- 22023-05-09浏览数:25044
- 42023-09-25浏览数:18519
- 52020-05-11浏览数:17526