需求:日期相减得到带小数点的天数差值
参考思路:informix 计算 日期之差_zhengqiqiqinqin的博客-CSDN博客_informix 时间差
写sql语句:
select (operatetimeforhis-inserttimeforhis) as dif1,* from a
into temp t1;
--把天数、时分秒都拆出来
select to_number(substr(dif1,1,9)) as t_day,to_number(substr(dif1,11,2)) as t_hour,to_number(substr(dif1,14,2)) as t_minu,to_number(substr(dif1,17,2)) as t_second,*
from t1
into temp t2;
--把时分秒换算成天加回去得到带小数点的天数。
select round((t_day+ (t_hour*3600+t_minu*60+t_second)*1.0/24/3600),2) as difday,operatetimeforhis,inserttimeforhis, * from t2