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

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

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

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

      MySQL STR_TO_DATE 函数不工作

      时间:2023-10-11
        <bdo id='NQRrA'></bdo><ul id='NQRrA'></ul>

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

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

                <tbody id='NQRrA'></tbody>
            1. <i id='NQRrA'><tr id='NQRrA'><dt id='NQRrA'><q id='NQRrA'><span id='NQRrA'><b id='NQRrA'><form id='NQRrA'><ins id='NQRrA'></ins><ul id='NQRrA'></ul><sub id='NQRrA'></sub></form><legend id='NQRrA'></legend><bdo id='NQRrA'><pre id='NQRrA'><center id='NQRrA'></center></pre></bdo></b><th id='NQRrA'></th></span></q></dt></tr></i><div id='NQRrA'><tfoot id='NQRrA'></tfoot><dl id='NQRrA'><fieldset id='NQRrA'></fieldset></dl></div>
              • 本文介绍了MySQL STR_TO_DATE 函数不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我只想将时间与另一个时间字符串进行比较,所以我使用 STR_TO_DATE 函数将我的时间字符串转换为日期时间格式

                I want only time to compare with another time string, so i am using STR_TO_DATE function to convert my time string to date time format

                下面的语句对我来说很好用,所以我认为 MySQL 没有任何问题

                Below statement works fine for me, so i think MySQL don't have any problem

                SELECT STR_TO_DATE('26/04/2011', '%d/%m/%Y');
                

                但我不知道为什么下面的对我不起作用

                But i don't know why below one is not working for me

                SELECT STR_TO_DATE('11:59:59','%h:%i:%s');  
                

                当我在 PhpMyAdmin 的 SQL 控制台中运行时,上述语句总是返回 NULL

                Above statement always return NULL when i run in SQL Console of PhpMyAdmin

                推荐答案

                这确实是因为 SQL 模式 NO_ZERO_DATE.当 Anand Rockzz 链接到手册时,您应该已经看到了,但该链接只是解释的一半.从 MySQL 5.7.4 开始,该设置已被弃用.在你的第一个例子中,你正在设置一个日期;在第二个中, NO_ZERO_DATE 导致返回 NULL,因为您没有指定日期.从 5.7.8 开始,NO_ZERO_DATENO_ZERO_IN_DATE 已包含在默认 sql_mode 值中.根据手册,看起来好像弃用和删除已部分恢复(从 5.7.8 开始),因此您可以在 my.cnf(或每个会话)中明确设置它.

                This is indeed because of the SQL mode NO_ZERO_DATE. You should have seen that when Anand Rockzz linked to the manual, but that link is only half of the explanation. As of MySQL 5.7.4, the setting is deprecated. In your first example, you're setting a date; in the second one, NO_ZERO_DATE causes the return of NULL because you're not specifying a date. Starting with 5.7.8, NO_ZERO_DATE and NO_ZERO_IN_DATE have been included with the default sql_mode value. According to the manual, it appears as if the deprecation and removal has been partially reverted (starting with 5.7.8), so you may be able to explicitly set this in your my.cnf (or per-session).

                您还应该参考有关的手册NO_ZERO_DATE 指令.

                You should also refer to the manual regarding the NO_ZERO_DATE directive.

                这篇关于MySQL STR_TO_DATE 函数不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:谁能帮我弄清楚这段代码有什么问题? 下一篇:SQL 选择字符串不起作用

                相关文章

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

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

                    <legend id='xbyBc'><style id='xbyBc'><dir id='xbyBc'><q id='xbyBc'></q></dir></style></legend>
                  2. <tfoot id='xbyBc'></tfoot>