oracle 中时间类型 date 与 long 互转

it2022-05-05  154

我们在保存时间到数据库时,有时候会保存long型的数据,固定长度是13位,是用当前时间减去1970-01-01,再换算成毫秒得到的结果。 但是要考虑到时区问题中国的时区时+8区所以时间要加上8小时

 

oracle中的实现方式:

 

 

----------------------------------------------

1,date转long :

当前时间转成long :

 

select sysdate,(sysdate-to_date('1970-01-01 08:00:00','yyyy-mm-dd hh24:mi:ss'))* 24*60*60*1000current_milli from dual;

 

 

2,long转date

 

select   to_date('1970-01-01 08:00:00','yyyy-mm-dd hh24:mi:ss')+   1241450728000/1000/24/60/60  from   dual

转载于:https://www.cnblogs.com/lambertwe/p/6116402.html

相关资源:各显卡算力对照表!

最新回复(0)