以毫秒为单位的两个日期时间之间的差异(Informix)

我可以找到类似的内容,以秒为单位找出差异。但我无法找到如何以毫秒为单位找到差异。以毫秒为单位的两个日期时间之间的差异(Informix)

select (start_time - datetime(2013-08-12 19:05:34.223) year to fraction(3)) 

::interval second(9) to second

from table1 where event_id = 1

回答:

首先,如果你真的想从数据库中毫秒的细节,你需要检查USEOSTIME参数被激活(默认不是)。
Informix仅将数据库配置为使用OS TIME(这意味着它们使用OS gettime()函数)时显示小数/毫秒。
当该选项被禁用时,小数部分总是为零。

如果未激活,您或DBA需要在onconfig文件中更改此设置并重新启动引擎。

只要小心,因为这会影响数据库中使用的所有时间戳。

select * from sysmaster:sysconfig where cf_name = 'USEOSTIME'; 

cf_id 54

cf_name USEOSTIME

cf_flags 0

cf_original 1

cf_effective 1

cf_default 0

1 row(s) retrieved.

drop table if exists tp01;

Table dropped.

create temp table tp01 (dt datetime year to fraction);

Temporary table created.

insert into tp01 values (current);

1 row(s) inserted.

select * from tp01;

dt

2013-10-18 08:29:36.864

1 row(s) retrieved.

select dt, current, (current - dt)::interval second(9) to fraction from tp01;

dt (expression) (expression)

2013-10-18 08:29:36.864 2013-10-18 08:29:36.864 0.000

1 row(s) retrieved.

select dt, current, ((current - dt)::interval second(9) to fraction)*1000 from tp01;

dt (expression) (expression)

2013-10-18 08:29:36.864 2013-10-18 08:29:36.865 1.000

1 row(s) retrieved.

这里,后等待8秒并且我重新运行上面的选择...

dt      (expression)   (expression) 

2013-10-18 08:30:44.539 2013-10-18 08:30:53.058 8.519

dt (expression) (expression)

2013-10-18 08:30:44.539 2013-10-18 08:30:53.058 8519.000

回答:

对不起,特定于Java代码,但下面是SQL代码,可以是有用的U:

select (datediff(ss,StartDate,EndDate)*1000) 

以上是 以毫秒为单位的两个日期时间之间的差异(Informix) 的全部内容, 来源链接: utcz.com/qa/265693.html

回到顶部