{"id":89902,"date":"2020-05-13T02:51:00","date_gmt":"2020-05-12T18:51:00","guid":{"rendered":"http:\/\/4563.org\/?p=89902"},"modified":"2020-05-13T02:51:00","modified_gmt":"2020-05-12T18:51:00","slug":"%e5%85%b3%e4%ba%8e-mysql-date_format%e5%87%bd%e6%95%b0%e7%9a%84%e7%96%91%e9%97%ae","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=89902","title":{"rendered":"\u5173\u4e8e mysql DATE_FORMAT()\u51fd\u6570\u7684\u7591\u95ee"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5173\u4e8e mysql DATE_FORMAT()\u51fd\u6570\u7684\u7591\u95ee               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : liubx <\/span>  <span><i><\/i> 10<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u4eca\u5929\u4e9b\u4e1a\u52a1\u4f7f\u7528\u4e86 springjdbc\uff0c\u53d1\u73b0\u4e86 DATE_FORMAT()\u7684\u4e00\u4e2a\u95ee\u9898\uff1a<\/p>\n<pre><code> select (DATE_FORMAT( '2018-12-31 10:37:12', '%Y-%m') = 2019-01) \u4e3a true       select (DATE_FORMAT( '2018-12-31 10:37:12', '%Y-%m') = '2019-01') \u4e3a false   <\/code><\/pre>\n<p>\u8bf7\u95ee\u4e3a\u4ec0\u4e48\u4f1a\u6709\u8fd9\u79cd\u7ed3\u679c\u554a\uff1f<\/p>\n<p>\u8fd8\u8981\u4e3a\u4ec0\u4e48 jdbc \u4e2d\u7684\u5b57\u7b26\u4e32\u8f6c\u6210 sql \u540e\u4e0d\u4f1a\u5e26\u4e0a\u5355\u5f15\u53f7\uff0c\u800c mybatis \u4f1a\u5e26\u4e0a\u5355\u5f15\u53f7\uff1f\u662f mybatis \u505a\u4e86\u8fd9\u4e00\u6b65\u5417\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>5<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1327662\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jzmws <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             select (DATE_FORMAT( &#8216;2018-12-31 10:37:12&#8217;, &#8216;%Y-%m&#8217;) = DATE_FORMAT( &#8216;2019-01&#8217;, &#8216;%Y-%m&#8217;) ) \u4e3a true                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1327663\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : qwerthhusn <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             2019-01 \u8fd9\u79cd\u4e1c\u897f\u662f\u5b57\u9762\u91cf\u5417\uff1f<br \/>select 2019-01 \u5f97\u5230\u7684\u5374\u662f 2018<br \/>\u4e0d\u77e5\u9053\u7f16\u8bd1\u5668\u600e\u4e48\u5f04\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1327664\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : panzhc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             select timestamp(&#8216;2020-04-28 23:06:00&#8217;) &#8211; timestamp(&#8216;2020-04-28 23:05:00&#8217;);<br \/>select timestamp(&#8216;2020-04-28 23:06:00&#8217;) &#8211; timestamp(&#8216;2020-04-28 23:05:30&#8217;);                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1327665\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : qwerthhusn <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             select DATE_FORMAT( &#8216;2018-12-31 10:37:12&#8217;, &#8216;%Y-%m&#8217;) = 2018; #\u8fd4\u56de 1<br \/>select DATE_FORMAT( &#8216;2018-12-31 10:37:12&#8217;, &#8216;%Y-%m&#8217;) = &#8216;2018&#8217;; #\u8fd4\u56de 0<br \/>select DATE_FORMAT( &#8216;2018-12-31 10:37:12&#8217;, &#8216;%Y-%m&#8217;) = &#8216;2018-12&#8217;; #\u8fd4\u56de 1<\/p>\n<p>\u90a3\u4e2a 2019-01 \u6ca1\u52a0\u5f15\u53f7\u4f1a\u53d8\u6210 2018\uff0c\u800c\u4e0a\u9762\u7684\u7b2c\u4e00\u884c\u4e5f\u662f true                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1327666\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Aresxue <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u52a0\u5b57\u7b26\u4e32\u4f1a\u8ba4\u4e3a\u662f\u6570\u5b57, 2019-01 \u4f1a\u88ab\u5f53\u505a 2019 &#8211; 1 = 2018, \u6240\u4ee5\u4f1a\u4e0d\u7b49, \u52a0\u4e0a\u5f15\u53f7\u624d\u662f\u5b57\u7b26\u4e32, \u5bf9\u4e8e\u4f60\u7a0b\u5e8f\u6765\u8bf4\u4f60\u662f String \u7c7b\u578b\u6240\u4ee5\u8f6c\u6210 sql \u5c31\u662f\u5e26\u5f15\u53f7\u7684\u5b57\u7b26\u4e32                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5173\u4e8e mysql DATE_FOR&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/89902"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=89902"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/89902\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=89902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=89902"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=89902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}