oracle 显示unix timestamp 自定义函数

来源:互联网 发布:梅花魂优化答案 编辑:程序博客网 时间:2024/05/20 00:35
create or replace function date_to_unix_ts( PDate in date ) return number is
   l_unix_ts number;
begin


   l_unix_ts := ( PDate - date '1970-01-01' ) * 60 * 60 * 24;
   return l_unix_ts;

end;



create or replace function unixts_to_date(p_timestamp number) return date
as
begin
return to_date('1970-01-01','YYYY-MM-DD') + 
numtodsinterval(p_timestamp,'SECOND');
end unixts_to_date;

0 0
原创粉丝点击