{"id":889,"date":"2020-09-01T14:08:36","date_gmt":"2020-09-01T06:08:36","guid":{"rendered":"http:\/\/www.gbase8.cn\/?p=889"},"modified":"2021-01-08T09:59:18","modified_gmt":"2021-01-08T01:59:18","slug":"gbase-8a%e6%95%b0%e6%8d%ae%e5%ba%93%e6%9f%90%e5%b9%b4%e7%ac%ac%e5%87%a0%e5%91%a8%e7%9a%84%e5%85%b7%e4%bd%93%e6%97%a5%e6%9c%9f","status":"publish","type":"post","link":"https:\/\/www.gbase8.cn\/en\/889","title":{"rendered":"\u5357\u5927\u901a\u7528GBase 8a\u6570\u636e\u5e93\u67d0\u5e74\u7b2c\u51e0\u5468\u7684\u5177\u4f53\u65e5\u671f"},"content":{"rendered":"<p>\u8ba1\u7b97\u67d0\u4e00\u5e74\u7684\u67d0\u4e00\u5468\uff0c\u662f\u54ea\u4e00\u5929\uff0c\u5176\u5b9e\u67097\u4e2a\uff0c\u968f\u4fbf\u51fa\u4e00\u4e2a\u5373\u53ef\uff0c\u4e5fyearweek\u51fd\u6570\u662f\u76f8\u53cd\u7684\u6548\u679c\u3002<\/p>\n\n\n\n<p>\u672c\u5468\u7b2c\u4e00\u5929\u6216\u6307\u5b9a\u65e5\u671f\u6240\u5728\u5468\u7684\u7b2c\u4e00\u5929\uff0c\u8bf7\u53c2\u8003 <a href=\"https:\/\/www.gbase8.cn\/en\/3020\/\">GBase 8a\u6570\u636e\u5e93\u83b7\u5f97\u672c\u5468\u7684\u7b2c\u4e00\u5929\uff0c\u6307\u5b9a\u65e5\u671f\u6240\u5728\u5468\u7684\u7b2c\u4e00\u5929\u7684\u65b9\u6cd5<\/a><\/p>\n\n\n\n<p>\u5982\u679c\u56fa\u5b9a\uff0c\u6bcf\u5e74\u7b2c\u4e00\u5468\u90fd\u662f\u4ece1\u67081\u65e5\u5f00\u59cb\uff0c\u90a3\u4e48\u7b80\u5355\u7684\u5c06\u5e74\u52a0\u4e0a1\u67081\u65e5\u5c31\u884c\u4e86\uff0c\u6bd4\u5982<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select concat(year,'-01-01')<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u662f\u5176\u5b83\u5468\uff0c\u53ef\u4ee5\u7528date_add\u589e\u52a0\u65e5\u671f\uff0c\u6bd4\u5982\uff0c\u867d\u7136\u4e0d\u662f\u90a3\u4e00\u5468\u7684\u7b2c\u4e00\u5929\uff0c\u4f46\u786e\u5b9e\u5c5e\u4e8e\u6307\u5b9a\u7684\u5468\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; select date_add('2020-01-01',interval 1 week);\n+----------------------------------------+\n| date_add('2020-01-01',interval 1 week) |\n+----------------------------------------+\n| 2020-01-08 00:00:00                    |\n+----------------------------------------+\n1 row in set (Elapsed: 00:00:00.00)\n<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u662f\u56fd\u9645\u6807\u51c6\uff0c\u90a3\u4e48\u5c31\u8981\u533a\u5206\u662f\u5468\u4e00\u662f\u7b2c\u4e00\u5929\u8fd8\u662f\u5468\u65e5\u662f\u7b2c\u4e00\u5929\uff0c\u5982\u679c\u662f\u5468\u4e00<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\ngbase&gt; select str_to_date(concat('202001',' Monday'),'%X%V %W');\n+---------------------------------------------------+\n| str_to_date(concat('202001',' Monday'),'%X%V %W') |\n+---------------------------------------------------+\n| 2020-01-06                                        |\n+---------------------------------------------------+\n1 row in set (Elapsed: 00:00:00.00)\n\ngbase&gt; select str_to_date(concat('202001',' Sunday'),'%x%v %W');\n+---------------------------------------------------+\n| str_to_date(concat('202001',' Sunday'),'%x%v %W') |\n+---------------------------------------------------+\n| 2020-01-05                                        |\n+---------------------------------------------------+\n1 row in set (Elapsed: 00:00:00.00)\n<\/code><\/pre>\n\n\n\n<p>\u6ce8\u610f\u5982\u679c\u662f\u5468\u4e00\uff0c\u90a3\u4e48\u7528\u5927\u5199\u7684%X\u548c%V, \u5982\u679c\u662f\u5468\u65e5\uff0c\u90a3\u4e48\u662f\u5c0f\u5199\u7684\u3002\u8be6\u60c5\u770bSQL\u624b\u518c\u91cc\u5173\u4e8eDATE_FORMAT\u51fd\u6570\u7684\u8bf4\u660e\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u5982\u4e0a\u7684\u5468\uff0c\u53ef\u4ee5\u662f\u4efb\u610f\u4e00\u5468\uff0c\u6bd4\u5982<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\ngbase&gt; select str_to_date(concat('202002',' Sunday'),'%x%v %W');\n+---------------------------------------------------+\n| str_to_date(concat('202002',' Sunday'),'%x%v %W') |\n+---------------------------------------------------+\n| 2020-01-12                                        |\n+---------------------------------------------------+\n1 row in set (Elapsed: 00:00:00.00)\n\ngbase&gt; select str_to_date(concat('202002',' Monday'),'%X%V %W');\n+---------------------------------------------------+\n| str_to_date(concat('202002',' Monday'),'%X%V %W') |\n+---------------------------------------------------+\n| 2020-01-13                                        |\n+---------------------------------------------------+\n1 row in set (Elapsed: 00:00:00.00)\n<\/code><\/pre>","protected":false},"excerpt":{"rendered":"<p>\u8ba1\u7b97\u67d0\u4e00\u5e74\u7684\u67d0\u4e00\u5468\uff0c\u662f\u54ea\u4e00\u5929\uff0c\u5176\u5b9e\u67097\u4e2a\uff0c\u968f\u4fbf\u51fa\u4e00\u4e2a\u5373\u53ef\uff0c\u4e5fyearweek\u51fd\u6570\u662f\u76f8\u53cd\u7684\u6548\u679c\u3002<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[67],"class_list":["post-889","post","type-post","status-publish","format-standard","hentry","category-gbase8a","tag-67"],"_links":{"self":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/889","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/comments?post=889"}],"version-history":[{"count":3,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/889\/revisions"}],"predecessor-version":[{"id":3038,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/889\/revisions\/3038"}],"wp:attachment":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/media?parent=889"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/categories?post=889"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/tags?post=889"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}