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

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

      1. <small id='XlmiW'></small><noframes id='XlmiW'>

      2. Oracle:如何将分钟添加到时间戳?

        时间:2023-09-19
          <bdo id='Nl9yE'></bdo><ul id='Nl9yE'></ul>

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

            <legend id='Nl9yE'><style id='Nl9yE'><dir id='Nl9yE'><q id='Nl9yE'></q></dir></style></legend>
              <tbody id='Nl9yE'></tbody>

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

                  本文介绍了Oracle:如何将分钟添加到时间戳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要为 Oracle 日期列中的值添加 30 分钟.我通过指定

                  I need to add 30 minutes to values in a Oracle date column. I do this in my SELECT statement by specifying

                  to_char(date_and_time + (.000694 * 31)

                  大部分时间都可以正常工作.但不是当时间在 AM/PM 边界时.例如,将 30 分钟添加到 12:30 [即 PM] 返回 1:00 即 AM.我期望的答案是 13:00.这样做的正确方法是什么?

                  which works fine most of the time. But not when the time is on the AM/PM border. For example, adding 30 minutes to 12:30 [which is PM] returns 1:00 which is AM. The answer I expect is 13:00. What's the correct way to do this?

                  推荐答案

                  所有其他答案基本上都正确,但我认为没有人直接回答您最初的问题.

                  All of the other answers are basically right but I don't think anyone's directly answered your original question.

                  假设您的示例中的date_and_time"是一个类型为 DATE 或 TIMESTAMP 的列,我认为您只需要对此进行更改:

                  Assuming that "date_and_time" in your example is a column with type DATE or TIMESTAMP, I think you just need to change this:

                  to_char(date_and_time + (.000694 * 31))
                  

                  为此:

                  to_char(date_and_time + (.000694 * 31), 'DD-MON-YYYY HH24:MI')
                  

                  听起来您的默认日期格式使用HH"代码表示小时,而不是HH24".

                  It sounds like your default date format uses the "HH" code for the hour, not "HH24".

                  此外,我认为您的常数项既令人困惑又不准确.我猜你所做的是计算出 (.000694) 大约是一分钟的值,然后将其乘以要添加的分钟数(示例中为 31,尽管您在文本中说的是 30).

                  Also, I think your constant term is both confusing and imprecise. I guess what you did is calculate that (.000694) is about the value of a minute, and you are multiplying it by the number of minutes you want to add (31 in the example, although you said 30 in the text).

                  我也会从一天开始,并将其划分为代码中所需的单位.在这种情况下,(1/48) 将是 30 分钟;或者,如果为了清楚起见,您想将其分解,可以写成 ( ((1/24) * (1/2) ).

                  I would also start with a day and divide it into the units you want within your code. In this case, (1/48) would be 30 minutes; or if you wanted to break it up for clarity, you could write ( (1/24) * (1/2) ).

                  这将避免舍入错误(浮点数固有的错误除外,这些错误在这里应该毫无意义)并且更清晰,至少对我而言.

                  This would avoid rounding errors (except for those inherent in floating point which should be meaningless here) and is clearer, at least to me.

                  这篇关于Oracle:如何将分钟添加到时间戳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 oracle 中使用 json 下一篇:ORA-01461: 只能为插入到 LONG 列而绑定 LONG 值-查询时发生

                  相关文章

                    <bdo id='EhpxY'></bdo><ul id='EhpxY'></ul>

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

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