{"id":21207,"date":"2024-01-02T06:42:25","date_gmt":"2024-01-02T06:42:25","guid":{"rendered":"https:\/\/server.hk\/blog\/21207\/"},"modified":"2024-11-14T10:37:44","modified_gmt":"2024-11-14T02:37:44","slug":"how-to-fix-postgresql-error-code-22008-datetime_field_overflow","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/21207\/","title":{"rendered":"\u5982\u4f55\u4fee\u5fa9 PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a22008 &#8211; datetime_field_overflow"},"content":{"rendered":"<h1>\u5982\u4f55\u4fee\u5fa9 PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a22008 &#8211; datetime_field_overflow<\/h1>\n<p>PostgreSQL \u662f\u4e00\u6b3e\u529f\u80fd\u5f37\u5927\u7684\u958b\u6e90\u95dc\u806f\u5f0f\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u5ee3\u6cdb\u7528\u65bc\u5404\u7a2e\u61c9\u7528\u3002\u7136\u800c\uff0c\u50cf\u6240\u6709\u8edf\u9ad4\u4e00\u6a23\uff0c\u5b83\u53ef\u80fd\u6703\u9047\u5230\u9700\u8981\u89e3\u6c7a\u7684\u932f\u8aa4\u3002\u5176\u4e2d\u4e00\u500b\u932f\u8aa4\u662f PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a22008 &#8211; datetime_field_overflow\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u8a72\u932f\u8aa4\u7684\u610f\u7fa9\u53ca\u4fee\u5fa9\u65b9\u6cd5\u3002<\/p>\n<h2>\u4e86\u89e3\u932f\u8aa4<\/h2>\n<p>PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a22008 &#8211; datetime_field_overflow \u662f\u7576\u5617\u8a66\u5c07\u4e00\u500b\u503c\u5b58\u5132\u5230\u8d85\u51fa\u63a5\u53d7\u7bc4\u570d\u7684\u65e5\u671f\u6642\u9593\u5b57\u6bb5\u6642\u767c\u751f\u7684\u3002\u6b64\u932f\u8aa4\u901a\u5e38\u767c\u751f\u5728\u63d2\u5165\u6216\u66f4\u65b0\u4e00\u500b\u8d85\u51fa\u6709\u6548\u7bc4\u570d\u7684\u65e5\u671f\u6642\u9593\u503c\u6642\u3002<\/p>\n<p>PostgreSQL \u652f\u63f4\u5404\u7a2e\u65e5\u671f\u6642\u9593\u6578\u64da\u985e\u578b\uff0c\u5982 <code>timestamp<\/code>\u3001<code>date<\/code> \u548c <code>time<\/code>\u3002\u9019\u4e9b\u6578\u64da\u985e\u578b\u5404\u81ea\u5177\u6709\u4e0d\u540c\u7684\u63a5\u53d7\u503c\u7bc4\u570d\u3002\u4f8b\u5982\uff0c<code>timestamp<\/code> \u6578\u64da\u985e\u578b\u53ef\u4ee5\u5b58\u5132\u7684\u503c\u7bc4\u570d\u662f\u5f9e\u516c\u5143\u524d 4713 \u5e74\u5230\u516c\u5143 294276 \u5e74\u3002<\/p>\n<h2>\u4fee\u5fa9\u932f\u8aa4<\/h2>\n<p>\u8981\u4fee\u5fa9 PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a22008 &#8211; datetime_field_overflow\uff0c\u60a8\u9700\u8981\u78ba\u4fdd\u60a8\u5617\u8a66\u63d2\u5165\u6216\u66f4\u65b0\u7684\u65e5\u671f\u6642\u9593\u503c\u5728\u7279\u5b9a\u65e5\u671f\u6642\u9593\u6578\u64da\u985e\u578b\u7684\u6709\u6548\u7bc4\u570d\u5167\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u89e3\u6c7a\u6b64\u932f\u8aa4\u7684\u4e00\u4e9b\u6b65\u9a5f\uff1a<\/p>\n<h3>1. \u6aa2\u67e5\u65e5\u671f\u6642\u9593\u503c<\/h3>\n<p>\u5be9\u67e5\u60a8\u5617\u8a66\u63d2\u5165\u6216\u66f4\u65b0\u7684\u65e5\u671f\u6642\u9593\u503c\u3002\u78ba\u4fdd\u5b83\u5728\u7279\u5b9a\u65e5\u671f\u6642\u9593\u6578\u64da\u985e\u578b\u7684\u6709\u6548\u7bc4\u570d\u5167\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f <code>timestamp<\/code> \u6578\u64da\u985e\u578b\uff0c\u5247\u78ba\u4fdd\u8a72\u503c\u5728\u516c\u5143\u524d 4713 \u5e74\u5230\u516c\u5143 294276 \u5e74\u4e4b\u9593\u3002<\/p>\n<h3>2. \u9a57\u8b49\u683c\u5f0f<\/h3>\n<p>\u78ba\u4fdd\u65e5\u671f\u6642\u9593\u503c\u7684\u683c\u5f0f\u7b26\u5408 PostgreSQL \u7684\u8981\u6c42\u3002\u4e0d\u540c\u7684\u65e5\u671f\u6642\u9593\u6578\u64da\u985e\u578b\u6709\u4e0d\u540c\u7684\u683c\u5f0f\u3002\u4f8b\u5982\uff0c<code>timestamp<\/code> \u6578\u64da\u985e\u578b\u9075\u5faa\u683c\u5f0f &#8216;YYYY-MM-DD HH:MI:SS&#8217;\u3002<\/p>\n<h3>3. \u4f7f\u7528\u9069\u7576\u7684\u51fd\u6578<\/h3>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u4f7f\u7528\u51fd\u6578\u6216\u8868\u9054\u5f0f\u64cd\u4f5c\u65e5\u671f\u6642\u9593\u503c\uff0c\u8acb\u78ba\u4fdd\u60a8\u4f7f\u7528\u7684\u662f\u9069\u5408\u7279\u5b9a\u65e5\u671f\u6642\u9593\u6578\u64da\u985e\u578b\u7684\u51fd\u6578\u3002PostgreSQL \u63d0\u4f9b\u4e86\u8a31\u591a\u51fd\u6578\u4f86\u64cd\u4f5c\u65e5\u671f\u6642\u9593\u503c\uff0c\u4f8b\u5982 <code>date_trunc<\/code>\u3001<code>extract<\/code> \u548c <code>interval<\/code>\u3002<\/p>\n<h3>4. \u8003\u616e\u6642\u5340<\/h3>\n<p>\u5982\u679c\u60a8\u7684\u61c9\u7528\u7a0b\u5e8f\u6d89\u53ca\u4e0d\u540c\u6642\u5340\u7684\u65e5\u671f\u6642\u9593\u503c\uff0c\u8acb\u78ba\u4fdd\u6b63\u78ba\u8655\u7406\u6642\u5340\u8f49\u63db\u3002PostgreSQL \u63d0\u4f9b\u4e86\u50cf <code>AT TIME ZONE<\/code> \u548c <code>timezone<\/code> \u7684\u51fd\u6578\u4f86\u9032\u884c\u6642\u5340\u8f49\u63db\u3002<\/p>\n<h3>5. \u66f4\u65b0 PostgreSQL \u7248\u672c<\/h3>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u4f7f\u7528\u8f03\u820a\u7248\u672c\u7684 PostgreSQL\uff0c\u5efa\u8b70\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002\u8f03\u65b0\u7248\u672c\u901a\u5e38\u5305\u542b\u4fee\u6b63\u932f\u8aa4\u548c\u6539\u9032\uff0c\u6709\u52a9\u65bc\u89e3\u6c7a\u65e5\u671f\u6642\u9593\u76f8\u95dc\u7684\u554f\u984c\u3002<\/p>\n<h2>\u7e3d\u7d50<\/h2>\n<p>\u7e3d\u7d50\u4f86\u8aaa\uff0cPostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a22008 &#8211; datetime_field_overflow \u767c\u751f\u5728\u5617\u8a66\u5b58\u5132\u8d85\u51fa\u6709\u6548\u7bc4\u570d\u7684\u65e5\u671f\u6642\u9593\u503c\u6642\u3002\u8981\u4fee\u5fa9\u6b64\u932f\u8aa4\uff0c\u8acb\u78ba\u4fdd\u65e5\u671f\u6642\u9593\u503c\u5728\u7279\u5b9a\u65e5\u671f\u6642\u9593\u6578\u64da\u985e\u578b\u7684\u63a5\u53d7\u7bc4\u570d\u5167\uff0c\u9a57\u8b49\u683c\u5f0f\uff0c\u4f7f\u7528\u9069\u7576\u7684\u51fd\u6578\uff0c\u6b63\u78ba\u8655\u7406\u6642\u5340\uff0c\u4ee5\u53ca\u8003\u616e\u66f4\u65b0\u5230 PostgreSQL \u7684\u6700\u65b0\u7248\u672c\u3002<\/p>\n<p>\u5982\u679c\u60a8\u9047\u5230 PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a22008 &#8211; datetime_field_overflow \u6216\u5176\u4ed6\u4efb\u4f55\u8207\u6578\u64da\u5eab\u76f8\u95dc\u7684\u554f\u984c\uff0cServer.HK \u53ef\u4ee5\u63d0\u4f9b\u53ef\u9760\u4e14\u9ad8\u6027\u80fd\u7684 VPS \u8a17\u7ba1\u89e3\u6c7a\u65b9\u6848\u3002\u6211\u5011\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2f VPS<\/a> \u8a17\u7ba1\u670d\u52d9\u5c08\u70ba\u6eff\u8db3\u4e0d\u540c\u898f\u6a21\u4f01\u696d\u7684\u9700\u6c42\u800c\u8a2d\u8a08\u3002\u7acb\u5373\u806f\u7d61\u6211\u5011\uff0c\u4e86\u89e3\u6211\u5011\u5982\u4f55\u80fd\u5e6b\u52a9\u60a8\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4fee\u5fa9 PostgreSQL &#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-21207","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=21207"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21207\/revisions"}],"predecessor-version":[{"id":24246,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21207\/revisions\/24246"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=21207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=21207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=21207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}