oracle unix时间戳与date转换


  

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;


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM