oracle 中时间类型 date 与 long 互转

时间:2017-08-11 18:24:17   收藏:0   阅读:294

原文:http://www.cnblogs.com/lambertwe/p/6116402.html

今天在项目中查询流程相关信息中,发现了其中的日期字段存的信息很奇怪,是一串数值,后面发现是long类型或者integer类型数值,然后就需要转行成相应的日期格式了。

在网上搜索一番得到解决:

1、date转long:

select sysdate, (sysdate-to_date(1970-01-01 08:00:00,yyyy-mm-dd hh24:mi:ss))* 24*60*60*1000 current_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

其中为什么是 1970-01-01 08:00:00  而不是 1970-01-01 00:00:00是因为我们是东八区呀。

 

原文:http://www.cnblogs.com/xiehongwei/p/7347279.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!