-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 固有のコードで申し訳ありませんが、以下は u に役立つ SQL コードです。

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