-1

我可以找到类似的东西来在几秒钟内找到差异。但我无法找到如何以毫秒为单位找到差异。

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
4

2 回答 2

3

首先,如果您真的想要数据库中的毫秒详细信息,您需要检查 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
于 2013-10-18T11:38:28.450 回答
-4

抱歉,对于 java 特定代码,但以下是对您有用的 sql 代码:

select (datediff(ss,StartDate,EndDate)*1000)
于 2013-10-18T05:38:16.710 回答