{"id":100,"date":"2019-12-04T16:25:25","date_gmt":"2019-12-04T08:25:25","guid":{"rendered":"http:\/\/blog.yuekegu.com\/?p=100"},"modified":"2019-12-07T00:45:59","modified_gmt":"2019-12-06T16:45:59","slug":"mysql%e6%9f%a5%e8%af%a2%e4%bb%8a%e5%a4%a9%e3%80%81%e6%98%a8%e5%a4%a9%e3%80%81%e6%9c%ac%e5%91%a8%e3%80%81%e6%9c%ac%e6%9c%88%e3%80%81%e6%9c%ac%e5%ad%a3%e3%80%81%e6%9c%ac%e5%b9%b4%e7%9a%84%e6%95%b0","status":"publish","type":"post","link":"https:\/\/blog.yuekegu.com\/?p=100","title":{"rendered":"MySQL\u67e5\u8be2\u4eca\u5929\u3001\u6628\u5929\u3001\u672c\u5468\u3001\u672c\u6708\u3001\u672c\u5b63\u3001\u672c\u5e74\u7684\u6570\u636e"},"content":{"rendered":"\n<p><strong>\u5b9e\u73b0\u67e5\u8be2\u51fa\u827e\u5bbe\u6d69\u65af\u8bb0\u5fc6\u89c4\u5f8b\u65f6\u95f4\u70b9\u7684\u6570\u636e<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT id,from_unixtime(pubdate) FROM sq_question WHERE TO_DAYS( NOW( ) ) - TO_DAYS(from_unixtime(pubdate)) IN (1,2,4,7,15,30);<\/code><\/pre>\n\n\n\n<p><strong>\u4eca\u5929<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select * from \u8868\u540d where to_days(\u65f6\u95f4\u5b57\u6bb5\u540d) = to_days(now());<\/code><\/pre>\n\n\n\n<p><strong>\u6628\u5929<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT * FROM \u8868\u540d WHERE TO_DAYS( NOW( ) ) - TO_DAYS( \u65f6\u95f4\u5b57\u6bb5\u540d) &lt;= 1<\/code><\/pre>\n\n\n\n<p><strong>\u8fd17\u5929<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT * FROM \u8868\u540d where DATE_SUB(CURDATE(), INTERVAL 7 DAY) &lt;= date(\u65f6\u95f4\u5b57\u6bb5\u540d)<\/code><\/pre>\n\n\n\n<p><strong>\u8fd130\u5929<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT * FROM \u8868\u540d where DATE_SUB(CURDATE(), INTERVAL 30 DAY) &lt;= date(\u65f6\u95f4\u5b57\u6bb5\u540d)<\/code><\/pre>\n\n\n\n<p><strong>\u672c\u6708<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT * FROM \u8868\u540d WHERE DATE_FORMAT( \u65f6\u95f4\u5b57\u6bb5\u540d, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )<\/code><\/pre>\n\n\n\n<p><strong>\u4e0a\u4e00\u6708<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT * FROM \u8868\u540d WHERE PERIOD_DIFF( date_format( now( ) , '%Y%m' ) , date_format( \u65f6\u95f4\u5b57\u6bb5\u540d, '%Y%m' ) ) =1<\/code><\/pre>\n\n\n\n<p><strong>\u67e5\u8be2\u672c\u5b63\u5ea6\u6570\u636e<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select * from `ht_invoice_information` where QUARTER(create_date)=QUARTER(now());<\/code><\/pre>\n\n\n\n<p><strong>\u67e5\u8be2\u4e0a\u5b63\u5ea6\u6570\u636e<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select * from `ht_invoice_information` where QUARTER(create_date)=QUARTER(DATE_SUB(now(),interval 1 QUARTER));<\/code><\/pre>\n\n\n\n<p><strong>\u67e5\u8be2\u672c\u5e74\u6570\u636e<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select * from `ht_invoice_information` where YEAR(create_date)=YEAR(NOW());<\/code><\/pre>\n\n\n\n<p><strong>\u67e5\u8be2\u4e0a\u5e74\u6570\u636e<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select * from `ht_invoice_information` where year(create_date)=year(date_sub(now(),interval 1 year));<\/code><\/pre>\n\n\n\n<p><strong>\u67e5\u8be2\u5f53\u524d\u8fd9\u5468\u7684\u6570\u636e<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT name,submittime FROM enterprise WHERE YEARWEEK(date_format(submittime,'%Y-%m-%d')) = YEARWEEK(now());<\/code><\/pre>\n\n\n\n<p><strong>\u67e5\u8be2\u4e0a\u5468\u7684\u6570\u636e<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT name,submittime FROM enterprise WHERE YEARWEEK(date_format(submittime,'%Y-%m-%d')) = YEARWEEK(now())-1;<\/code><\/pre>\n\n\n\n<p><strong>\u67e5\u8be2\u4e0a\u4e2a\u6708\u7684\u6570\u636e<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>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 <\/code><\/pre>\n\n\n\n<p><strong>\u67e5\u8be2\u5f53\u524d\u6708\u4efd\u7684\u6570\u636e&nbsp;<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select name,submittime from enterprise   where date_format(submittime,'%Y-%m')=date_format(now(),'%Y-%m')<\/code><\/pre>\n\n\n\n<p><strong>\u67e5\u8be2\u8ddd\u79bb\u5f53\u524d\u73b0\u57286\u4e2a\u6708\u7684\u6570\u636e<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select name,submittime from enterprise where submittime between date_sub(now(),interval 6 month) and now();<\/code><\/pre>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u5b9e\u73b0\u67e5\u8be2\u51fa\u827e\u5bbe\u6d69\u65af\u8bb0\u5fc6\u89c4\u5f8b\u65f6\u95f4\u70b9\u7684\u6570\u636e \u4eca\u5929 \u6628\u5929 \u8fd17\u5929 \u8fd130\u5929 \u672c\u6708 \u4e0a\u4e00\u6708 \u67e5\u8be2\u672c\u5b63\u5ea6\u6570\u636e \u67e5\u8be2\u4e0a\u5b63\u5ea6 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.yuekegu.com\/?p=100\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cMySQL\u67e5\u8be2\u4eca\u5929\u3001\u6628\u5929\u3001\u672c\u5468\u3001\u672c\u6708\u3001\u672c\u5b63\u3001\u672c\u5e74\u7684\u6570\u636e\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"post_thumbnail_image":"","content_first_image":"","post_medium_image_300":"","post_thumbnail_image_624":"","post_frist_image":"","post_medium_image":"","post_large_image":"","post_full_image":"","post_all_images":[],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":5,"total_comments":0,"category_name":"Mysql","post_date":"2019-12-04","like_count":"0","praiseWord":"\u9f13\u52b1","copyright_state":"","excitationAd":"0","rewardedVideoAdId":"","detailAdId":"","detailAd":"0","enterpriseMinapp":"0","audios":[],"postImageUrl":false,"avatarurls":[],"related_posts":null,"pageviews":548,"next_post_id":409,"next_post_title":"MySQL \u5168\u6587\u7d22\u5f15 \u5b9e\u73b0\u76f8\u4f3c\u5ea6\u641c\u7d22","previous_post_id":null,"previous_post_title":null,"_links":{"self":[{"href":"https:\/\/blog.yuekegu.com\/index.php?rest_route=\/wp\/v2\/posts\/100"}],"collection":[{"href":"https:\/\/blog.yuekegu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.yuekegu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.yuekegu.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.yuekegu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=100"}],"version-history":[{"count":2,"href":"https:\/\/blog.yuekegu.com\/index.php?rest_route=\/wp\/v2\/posts\/100\/revisions"}],"predecessor-version":[{"id":103,"href":"https:\/\/blog.yuekegu.com\/index.php?rest_route=\/wp\/v2\/posts\/100\/revisions\/103"}],"wp:attachment":[{"href":"https:\/\/blog.yuekegu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.yuekegu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.yuekegu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}