【Oracle】 date与数字时间戳互转

前言

  • Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
  • PL/SQL 11.0.2.1766

date转数字时间戳

select 
(sysdate - date'1970-01-01' - TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone), 1, 3))/24)*(3600*24*1000) timestamp 
from dual;

在这里插入图片描述

数字时间戳转date

select 
to_date('1970101','yyyymmdd')+(1576049678000/(3600*24*1000))+TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone), 1, 3))/24 datetime 
from dual;

在这里插入图片描述

发布了284 篇原创文章 · 获赞 54 · 访问量 42万+

猜你喜欢

转载自blog.csdn.net/sayyy/article/details/103493471