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

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

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

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

      1. 如何在 MySQL 上获取两个日期之间相差的天数?

        时间:2023-08-18
        <legend id='9rTpj'><style id='9rTpj'><dir id='9rTpj'><q id='9rTpj'></q></dir></style></legend>

          <small id='9rTpj'></small><noframes id='9rTpj'>

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

              • <tfoot id='9rTpj'></tfoot>
                • <bdo id='9rTpj'></bdo><ul id='9rTpj'></ul>

                  本文介绍了如何在 MySQL 上获取两个日期之间相差的天数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我需要获取 MySQL 上几个日期中包含的天数.

                  I need to get the number of days contained within a couple of dates on MySQL.

                  例如:

                  • 入住日期是 12-04-2010
                  • 退房日期 15-04-2010

                  日差为 3.

                  推荐答案

                  DATEDIFF 函数?

                  What about the DATEDIFF function ?

                  引用手册页:

                  DATEDIFF() 返回 expr1 – expr2表示为从一开始的天数约会到另一个.expr1 和 expr2是日期或日期和时间表达式.只有值的日期部分是用于计算

                  DATEDIFF() returns expr1 – expr2 expressed as a value in days from one date to the other. expr1 and expr2 are date or date-and-time expressions. Only the date parts of the values are used in the calculation


                  在你的情况下,你会使用:


                  In your case, you'd use :

                  mysql> select datediff('2010-04-15', '2010-04-12');
                  +--------------------------------------+
                  | datediff('2010-04-15', '2010-04-12') |
                  +--------------------------------------+
                  |                                    3 | 
                  +--------------------------------------+
                  1 row in set (0,00 sec)
                  

                  但请注意,日期应写为YYYY-MM-DD,而不是像您发布的那样DD-MM-YYYY.

                  But note the dates should be written as YYYY-MM-DD, and not DD-MM-YYYY like you posted.

                  这篇关于如何在 MySQL 上获取两个日期之间相差的天数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:检查 MySQL 中日期范围的重叠 下一篇:如何在 MySql 中进行重音敏感搜索

                  相关文章

                  最新文章

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

                      <legend id='0NkLj'><style id='0NkLj'><dir id='0NkLj'><q id='0NkLj'></q></dir></style></legend>

                        <bdo id='0NkLj'></bdo><ul id='0NkLj'></ul>
                    3. <small id='0NkLj'></small><noframes id='0NkLj'>