{"id":703,"date":"2020-04-18T23:11:27","date_gmt":"2020-04-18T15:11:27","guid":{"rendered":"https:\/\/www.dd-home.top\/?p=703"},"modified":"2020-04-18T23:11:27","modified_gmt":"2020-04-18T15:11:27","slug":"mysql-%e6%a0%b9%e6%8d%ae%e6%97%b6%e9%97%b4%e7%9a%84%e7%ad%9b%e9%80%89%e8%af%ad%e5%8f%a5","status":"publish","type":"post","link":"https:\/\/www.dd-home.top\/?p=703","title":{"rendered":"Mysql \u6839\u636e\u65f6\u95f4\u7684\u7b5b\u9009\u8bed\u53e5"},"content":{"rendered":"<p>\u5f15\u7528 https:\/\/www.cnblogs.com\/shuilangyizu\/p\/8805384.html<\/p>\n<pre class=\"lang:java decode:true \">--\u4eca\u5929\n\nselect * from \u8868\u540d where to_days(\u65f6\u95f4\u5b57\u6bb5\u540d) = to_days(now());\n\n--\u6628\u5929\n\nSELECT * FROM \u8868\u540d WHERE TO_DAYS( NOW( ) ) - TO_DAYS( \u65f6\u95f4\u5b57\u6bb5\u540d) &lt;= 1<\/pre>\n<pre class=\"\">AND TO_DAYS(NOW()) - TO_DAYS(update_time)&gt;0<\/pre>\n<pre class=\"lang:java decode:true \">--\u672c\u5468 SELECT * FROM \u8868\u540d WHERE YEARWEEK( date_format( \u65f6\u95f4\u5b57\u6bb5\u540d,'%Y-%m-%d' ) ) = YEARWEEK( now() ) ; --\u672c\u6708 SELECT * FROM \u8868\u540d WHERE DATE_FORMAT( \u65f6\u95f4\u5b57\u6bb5\u540d, '%Y%m' ) = DATE_FORMAT( CURDATE( ) ,'%Y%m' ) --\u4e0a\u4e00\u4e2a\u6708 SELECT * FROM \u8868\u540d WHERE PERIOD_DIFF(date_format(now(),'%Y%m'),date_format(\u65f6\u95f4\u5b57\u6bb5\u540d,'%Y%m') =1 --\u672c\u5e74 SELECT * FROM \u8868\u540d WHERE YEAR( \u65f6\u95f4\u5b57\u6bb5\u540d ) = YEAR( NOW( ) ) --\u4e0a\u4e00\u6708 SELECT * FROM \u8868\u540d WHERE PERIOD_DIFF( date_format( now( ) , '%Y%m' ) , date_format( \u65f6\u95f4\u5b57\u6bb5\u540d, '%Y%m' ) ) =1 --\u67e5\u8be2\u672c\u5b63\u5ea6\u6570\u636e select * from `ht_invoice_information` where QUARTER(create_date)=QUARTER(now()); --\u67e5\u8be2\u4e0a\u5b63\u5ea6\u6570\u636e select * from `ht_invoice_information` where QUARTER(create_date)=QUARTER(DATE_SUB(now(),interval 1 QUARTER)); --\u67e5\u8be2\u672c\u5e74\u6570\u636e select * from `ht_invoice_information` where YEAR(create_date)=YEAR(NOW()); --\u67e5\u8be2\u4e0a\u5e74\u6570\u636e select * from `ht_invoice_information` where year(create_date)=year(date_sub(now(),interval 1 year)); --\u67e5\u8be2\u5f53\u524d\u8fd9\u5468\u7684\u6570\u636e SELECT name,submittime FROM enterprise WHERE YEARWEEK(date_format(submittime,'%Y-%m-%d')) = YEARWEEK(now()); --\u67e5\u8be2\u4e0a\u5468\u7684\u6570\u636e SELECT name,submittime FROM enterprise WHERE YEARWEEK(date_format(submittime,'%Y-%m-%d')) = YEARWEEK(now())-1; --\u67e5\u8be2\u5f53\u524d\u6708\u4efd\u7684\u6570\u636e select name,submittime from enterprise where date_format(submittime,'%Y-%m')=date_format(now(),'%Y-%m') --\u67e5\u8be2\u8ddd\u79bb\u5f53\u524d\u73b0\u57286\u4e2a\u6708\u7684\u6570\u636e select name,submittime from enterprise where submittime between date_sub(now(),interval 6 month) and now(); --\u67e5\u8be2\u4e0a\u4e2a\u6708\u7684\u6570\u636e select name,submittime from enterprise where date_format(submittime,'%Y-%m')=date_format(DATE_SUB(curdate(), INTERVAL 1 MONTH),'%Y-%m') select * from ` user ` where DATE_FORMAT(pudate, ' %Y%m ' ) = DATE_FORMAT(CURDATE(), ' %Y%m ' ) ; select * from user where WEEKOFYEAR(FROM_UNIXTIME(pudate,'%y-%m-%d')) = WEEKOFYEAR(now()) select * from user where MONTH (FROM_UNIXTIME(pudate, ' %y-%m-%d ' )) = MONTH (now()) select * from [ user ] where YEAR (FROM_UNIXTIME(pudate, ' %y-%m-%d ' )) = YEAR (now()) and MONTH (FROM_UNIXTIME(pudate, ' %y-%m-%d ' )) = MONTH (now()) select * from [ user ] where pudate between \u4e0a\u6708\u6700\u540e\u4e00\u5929 and \u4e0b\u6708\u7b2c\u4e00\u5929 where date(regdate) = curdate(); select * from test where year(regdate)=year(now()) and month(regdate)=month(now()) and day(regdate)=day(now()) SELECT date( c_instime ) ,curdate( ) FROM `t_score` WHERE 1 LIMIT 0 , 30<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5f15\u7528 https:\/\/www.cnblogs.com\/shuilangyizu\/p\/8805384.html  &hellip; <a href=\"https:\/\/www.dd-home.top\/?p=703\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">Mysql \u6839\u636e\u65f6\u95f4\u7684\u7b5b\u9009\u8bed\u53e5<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[],"class_list":["post-703","post","type-post","status-publish","format-standard","hentry","category-sql"],"_links":{"self":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/posts\/703","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=703"}],"version-history":[{"count":0,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/posts\/703\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=703"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=703"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=703"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}