• <legend id='asjpj'><style id='asjpj'><dir id='asjpj'><q id='asjpj'></q></dir></style></legend>
        <bdo id='asjpj'></bdo><ul id='asjpj'></ul>

        <small id='asjpj'></small><noframes id='asjpj'>

        <i id='asjpj'><tr id='asjpj'><dt id='asjpj'><q id='asjpj'><span id='asjpj'><b id='asjpj'><form id='asjpj'><ins id='asjpj'></ins><ul id='asjpj'></ul><sub id='asjpj'></sub></form><legend id='asjpj'></legend><bdo id='asjpj'><pre id='asjpj'><center id='asjpj'></center></pre></bdo></b><th id='asjpj'></th></span></q></dt></tr></i><div id='asjpj'><tfoot id='asjpj'></tfoot><dl id='asjpj'><fieldset id='asjpj'></fieldset></dl></div>
        <tfoot id='asjpj'></tfoot>

      1. 以毫秒为单位计算 Oracle 中两个时间戳之间的差异

        时间:2023-09-20

        1. <tfoot id='ljPse'></tfoot>

          <small id='ljPse'></small><noframes id='ljPse'>

            <tbody id='ljPse'></tbody>

        2. <i id='ljPse'><tr id='ljPse'><dt id='ljPse'><q id='ljPse'><span id='ljPse'><b id='ljPse'><form id='ljPse'><ins id='ljPse'></ins><ul id='ljPse'></ul><sub id='ljPse'></sub></form><legend id='ljPse'></legend><bdo id='ljPse'><pre id='ljPse'><center id='ljPse'></center></pre></bdo></b><th id='ljPse'></th></span></q></dt></tr></i><div id='ljPse'><tfoot id='ljPse'></tfoot><dl id='ljPse'><fieldset id='ljPse'></fieldset></dl></div>
        3. <legend id='ljPse'><style id='ljPse'><dir id='ljPse'><q id='ljPse'></q></dir></style></legend>

                  <bdo id='ljPse'></bdo><ul id='ljPse'></ul>
                  本文介绍了以毫秒为单位计算 Oracle 中两个时间戳之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何计算 Oracle 中两个时间戳之间的时间差(以毫秒为单位)?

                  How do I calculate the time difference in milliseconds between two timestamps in Oracle?

                  推荐答案

                  当你减去两个 TIMESTAMP 类型的变量时,你得到一个 INTERVAL DAY TO SECOND,其中包括一个取决于平台的毫秒数和/或微秒数.如果数据库在 Windows 上运行,systimestamp 通常会有毫秒.如果数据库在 Unix 上运行,systimestamp 通常会有微秒.

                  When you subtract two variables of type TIMESTAMP, you get an INTERVAL DAY TO SECOND which includes a number of milliseconds and/or microseconds depending on the platform. If the database is running on Windows, systimestamp will generally have milliseconds. If the database is running on Unix, systimestamp will generally have microseconds.

                    1  select systimestamp - to_timestamp( '2012-07-23', 'yyyy-mm-dd' )
                    2*   from dual
                  SQL> /
                  
                  SYSTIMESTAMP-TO_TIMESTAMP('2012-07-23','YYYY-MM-DD')
                  ---------------------------------------------------------------------------
                  +000000000 14:51:04.339000000
                  

                  您可以使用 EXTRACT 函数来提取 INTERVAL DAY TO SECOND 的各个元素

                  You can use the EXTRACT function to extract the individual elements of an INTERVAL DAY TO SECOND

                  SQL> ed
                  Wrote file afiedt.buf
                  
                    1  select extract( day from diff ) days,
                    2         extract( hour from diff ) hours,
                    3         extract( minute from diff ) minutes,
                    4         extract( second from diff ) seconds
                    5    from (select systimestamp - to_timestamp( '2012-07-23', 'yyyy-mm-dd' ) diff
                    6*           from dual)
                  SQL> /
                  
                        DAYS      HOURS    MINUTES    SECONDS
                  ---------- ---------- ---------- ----------
                           0         14         55     37.936
                  

                  然后您可以将这些组件中的每一个转换为毫秒并将它们相加

                  You can then convert each of those components into milliseconds and add them up

                  SQL> ed
                  Wrote file afiedt.buf
                  
                    1  select extract( day from diff )*24*60*60*1000 +
                    2         extract( hour from diff )*60*60*1000 +
                    3         extract( minute from diff )*60*1000 +
                    4         round(extract( second from diff )*1000) total_milliseconds
                    5    from (select systimestamp - to_timestamp( '2012-07-23', 'yyyy-mm-dd' ) diff
                    6*           from dual)
                  SQL> /
                  
                  TOTAL_MILLISECONDS
                  ------------------
                            53831842
                  

                  然而,通常情况下,使用 INTERVAL DAY TO SECOND 表示或为小时、分钟、秒等设置单独的列比计算之间的总毫秒数更有用两个 TIMESTAMP 值.

                  Normally, however, it is more useful to have either the INTERVAL DAY TO SECOND representation or to have separate columns for hours, minutes, seconds, etc. rather than computing the total number of milliseconds between two TIMESTAMP values.

                  这篇关于以毫秒为单位计算 Oracle 中两个时间戳之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Oracle中用户和模式之间的区别? 下一篇:oracle中的base64编解码

                  相关文章

                  <tfoot id='MPk2B'></tfoot>

                    <i id='MPk2B'><tr id='MPk2B'><dt id='MPk2B'><q id='MPk2B'><span id='MPk2B'><b id='MPk2B'><form id='MPk2B'><ins id='MPk2B'></ins><ul id='MPk2B'></ul><sub id='MPk2B'></sub></form><legend id='MPk2B'></legend><bdo id='MPk2B'><pre id='MPk2B'><center id='MPk2B'></center></pre></bdo></b><th id='MPk2B'></th></span></q></dt></tr></i><div id='MPk2B'><tfoot id='MPk2B'></tfoot><dl id='MPk2B'><fieldset id='MPk2B'></fieldset></dl></div>

                      <legend id='MPk2B'><style id='MPk2B'><dir id='MPk2B'><q id='MPk2B'></q></dir></style></legend>

                      <small id='MPk2B'></small><noframes id='MPk2B'>

                      • <bdo id='MPk2B'></bdo><ul id='MPk2B'></ul>