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

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

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

        如何在 MySQL 中将字符串转换为日期?

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

              <legend id='zxQqO'><style id='zxQqO'><dir id='zxQqO'><q id='zxQqO'></q></dir></style></legend>
            • <small id='zxQqO'></small><noframes id='zxQqO'>

                  <tbody id='zxQqO'></tbody>

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

                  <bdo id='zxQqO'></bdo><ul id='zxQqO'></ul>
                  本文介绍了如何在 MySQL 中将字符串转换为日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一个 string 列作为 date 并且我想选择它作为 DATE.

                  I have a string column which acts as a date and I want to select it as a DATE.

                  有可能吗?

                  我的示例数据格式是:

                  月/日/年 ->12/31/2011

                  推荐答案

                  正如在 MySQL 使用带有日期文本的字符串列作为日期字段,你可以这样做

                  As was told at MySQL Using a string column with date text as a date field, you can do

                  SELECT  STR_TO_DATE(yourdatefield, '%m/%d/%Y')
                  FROM    yourtable
                  

                  您还可以在 WHERE 子句中处理这些日期字符串.例如

                  You can also handle these date strings in WHERE clauses. For example

                  SELECT whatever
                    FROM yourtable
                   WHERE STR_TO_DATE(yourdatefield, '%m/%d/%Y') > CURDATE() - INTERVAL 7 DAY
                  

                  您可以通过这种方式处理各种日期/时间布局.请参考格式说明符DATE_FORMAT() 函数 看看你可以把什么放入 STR_TO_DATE() 的第二个参数中.

                  You can handle all kinds of date/time layouts this way. Please refer to the format specifiers for the DATE_FORMAT() function to see what you can put into the second parameter of STR_TO_DATE().

                  这篇关于如何在 MySQL 中将字符串转换为日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:从 MySQL 中的分层数据生成基于深度的树(无 CTE) 下一篇:重新排序/重置自动增量主键

                  相关文章

                  最新文章

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

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

                    • <bdo id='rMQO2'></bdo><ul id='rMQO2'></ul>
                    <tfoot id='rMQO2'></tfoot>

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