1、Unix 转换成时间
create or replace function INT2TIME(in_number NUMBER)
return date
is begin
if in_number < -3786854743 or in_number > 2208960000 then
return null;
else
return(TO_DATE('19700101', 'yyyymmdd') + in_number / 86400 + TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone), 1, 3)) / 24);
end if;
end INT2TIME;
2、从时间转换成INT
create or replace function TIME2INT(in_date IN DATE) return number is
begin
return round(((in_date - TO_DATE('19700101', 'yyyymmdd')) * 86400 -
TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone), 1, 3)) * 3600),
0);
end TIME2INT;
3、查询示例
select time,int2time(time)
from 表名称 c where
c.time >= time2int(to_date('2019-11-01','yyyy-MM-dd'))