linux 时间戳 转date:
 
创建自定义函数:
create or replace function unix_to_oracle(in_number number) return date is
begin
  return (to_date('19700101','yyyymmdd') + in_number/86400
  + to_number(substr(tz_offset(sessiontimezone),1,3))/24);
 
end unix_to_oracle;

 

 使用:
select unix_to_oracle(1509490525) from dual;

 

 
 
date 转linux时间戳:
 
create or replace function oracle_to_unix(in_date in date) return number is
begin
  return ((in_date-to_date('19700101','yyyymmdd'))*86400 -
  to_number(substr(tz_offset(sessiontimezone),1,3))*3600);
  end oracle_to_unix;

 

 使用:
select oracle_to_unix(sysdate) from dual;

转载于:https://www.cnblogs.com/Springmoon-venn/p/7767779.html

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐