【发布时间】:2016-07-19 08:00:47
【问题描述】:
我想从 oracle 的日期字段中获取日期“01-01-9999”的毫秒数。
我已经创建了下面的块来实现同样的效果。
set serveroutput on;
declare
base_point constant timestamp := to_timestamp_tz('01-JAN-1970 00:00:00.000+00:00', 'DD-Mon-RR HH24:MI:SS.FFTZH:TZM') AT TIME ZONE 'UTC';
now timestamp := to_timestamp_tz('01-01-2099 00:00:00.000+00:00', 'DD-MM-RR HH24:MI:SS.FFTZH:TZM') AT TIME ZONE 'UTC';
-- now constant timestamp := systimestamp AT TIME ZONE 'UTC' ;
n number;
begin
select to_timestamp_tz(to_char(todate,'DD-MM-YY HH24:MI:SS')||'.000+00:00','DD-MM-YY HH24:MI:SS.FFTZH:TZM')
into now
from t_table where ACCOUNTID = 'ACC001124211';
DBMS_OUTPUT.put_line(' now :'||now);
n := (
((extract(day from (now-base_point)))*86400)
+ ((extract(hour from (now-base_point)))*3600)
+ ((extract(minute from (now-base_point)))*60)
+ ((extract(second from (now-base_point))))
) * 1000;
DBMS_OUTPUT.put_line(' n :'||n);
end;
/
但是使用上面的块我得到的值是4070908800000,它等于日期1/1/2099,但我表中的实际日期是01-01-9999
您能否帮助我们使用日期字段获得精确的毫秒数
【问题讨论】:
标签: database oracle oracle11g oracle10g