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

    2. <legend id='4ByTB'><style id='4ByTB'><dir id='4ByTB'><q id='4ByTB'></q></dir></style></legend><tfoot id='4ByTB'></tfoot>
    3. <small id='4ByTB'></small><noframes id='4ByTB'>

        使用 to_char 格式化间隔

        时间:2023-09-20
          <i id='aq4s9'><tr id='aq4s9'><dt id='aq4s9'><q id='aq4s9'><span id='aq4s9'><b id='aq4s9'><form id='aq4s9'><ins id='aq4s9'></ins><ul id='aq4s9'></ul><sub id='aq4s9'></sub></form><legend id='aq4s9'></legend><bdo id='aq4s9'><pre id='aq4s9'><center id='aq4s9'></center></pre></bdo></b><th id='aq4s9'></th></span></q></dt></tr></i><div id='aq4s9'><tfoot id='aq4s9'></tfoot><dl id='aq4s9'><fieldset id='aq4s9'></fieldset></dl></div>
            <bdo id='aq4s9'></bdo><ul id='aq4s9'></ul>
                <tbody id='aq4s9'></tbody>

                <tfoot id='aq4s9'></tfoot>

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

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

                  本文介绍了使用 to_char 格式化间隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  遵循 SQL 命令

                  select TO_CHAR(NVL(arg1 - arg2, TO_DSINTERVAL('0 00:00:00'))) from table1
                  

                  产生以下格式的结果:+000000000 00:03:01.954000.

                  produces a result of the format: +000000000 00:03:01.954000.

                  是否可以在to_char函数中输入特殊格式才能得到格式的结果:+00 00:00:00.000?

                  Is it possible to enter a special format in the to_char function in order to get a result of format: +00 00:00:00.000?

                  推荐答案

                  我意识到它根本不聪明,也不是您正在寻找的特殊格式字符串,但是鉴于输出是固定的,这个答案确实有效长度:

                  I realize it's not clever at all, nor is it the special format string you're looking for, but this answer does work, given that the output is fixed length:

                  SELECT    SUBSTR(TO_CHAR(NVL(arg1 - arg2, TO_DSINTERVAL('0 00:00:00'))), 1, 1)
                         || SUBSTR(TO_CHAR(NVL(arg1 - arg2, TO_DSINTERVAL('0 00:00:00'))), 9, 2)
                         || ' '
                         || SUBSTR(TO_CHAR(NVL(arg1 - arg2, TO_DSINTERVAL('0 00:00:00'))), 12, 12)
                    FROM table1;
                  

                  它也只是截断了小数秒而不是四舍五入,但我从你的例子中假设它们无论如何都只是零.

                  It also just truncs the fractional seconds instead of rounding, but I assume from your example they're all just zeros anyway.

                  这是一个更大的尴尬,但我无法抗拒:

                  This is an even greater embarrassment, but I couldn't resist:

                  SELECT SUBSTR(REPLACE(TO_CHAR(NVL(arg1 - arg2, TO_DSINTERVAL('0 00:00:00')))
                                       , '0000000', '')
                               , 1, 16)
                    FROM table1;
                  

                  这篇关于使用 to_char 格式化间隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用“IN"Oracle SQL 中 replace() 函数输出中带有逗号分隔字符串的子句 下一篇:NLS_NUMERIC_CHARACTERS 十进制设置

                  相关文章

                    <legend id='9yvQ8'><style id='9yvQ8'><dir id='9yvQ8'><q id='9yvQ8'></q></dir></style></legend>
                    1. <tfoot id='9yvQ8'></tfoot>

                      <i id='9yvQ8'><tr id='9yvQ8'><dt id='9yvQ8'><q id='9yvQ8'><span id='9yvQ8'><b id='9yvQ8'><form id='9yvQ8'><ins id='9yvQ8'></ins><ul id='9yvQ8'></ul><sub id='9yvQ8'></sub></form><legend id='9yvQ8'></legend><bdo id='9yvQ8'><pre id='9yvQ8'><center id='9yvQ8'></center></pre></bdo></b><th id='9yvQ8'></th></span></q></dt></tr></i><div id='9yvQ8'><tfoot id='9yvQ8'></tfoot><dl id='9yvQ8'><fieldset id='9yvQ8'></fieldset></dl></div>
                        <bdo id='9yvQ8'></bdo><ul id='9yvQ8'></ul>
                    2. <small id='9yvQ8'></small><noframes id='9yvQ8'>