{"id":5312,"date":"2024-11-14T12:33:25","date_gmt":"2024-11-14T04:33:25","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5312\/"},"modified":"2024-11-14T12:33:25","modified_gmt":"2024-11-14T04:33:25","slug":"oracle%e6%80%8e%e4%b9%88%e8%bd%ac%e6%8d%a2%e6%97%a5%e6%9c%9f%e6%a0%bc%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5312\/","title":{"rendered":"oracle\u600e\u4e48\u8f6c\u6362\u65e5\u671f\u683c\u5f0f"},"content":{"rendered":"<blockquote><p>\n  \u5728 oracle \u4e2d\uff0c\u53ef\u4f7f\u7528 to_char() \u51fd\u6570\u8f6c\u6362\u65e5\u671f\u683c\u5f0f\uff0c\u8bed\u6cd5\u4e3a\uff1ato_char(date_expression, &#8216;format_mask&#8217;)\u3002\u53c2\u6570 date_expression \u6307\u5b9a\u8981\u8f6c\u6362\u7684\u65e5\u671f\u8868\u8fbe\u5f0f\u3002\u683c\u5f0f\u8499\u7248 format_mask \u6307\u5b9a\u8f93\u51fa\u683c\u5f0f\uff0c\u5176\u4e2d yyyy \u4ee3\u8868\u56db\u4f4d\u6570\u5e74\u4efd\uff0cmm \u4ee3\u8868\u4e24\u4f4d\u6570\u6708\u4efd\uff0cdd \u4ee3\u8868\u4e24\u4f4d\u6570\u65e5\u671f\uff0chh \u4ee3\u8868 12 \u5c0f\u65f6\u5236\u5c0f\u65f6\uff0cmi \u4ee3\u8868\u5206\u949f\uff0css \u4ee3\u8868\u79d2\u3002\u4f8b\u5982\uff0c\u5c06\u65e5\u671f &#8216;2023-03-08&#8242; \u8f6c\u6362\u4e3a &#8217;08-03-2023&#8217; \u683c\u5f0f\uff1ato_char(&#8216;\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/26\/2024052619123831276.jpg\" class=\"aligncenter\" title=\"oracle\u600e\u4e48\u8f6c\u6362\u65e5\u671f\u683c\u5f0f\u63d2\u56fe\" alt=\"oracle\u600e\u4e48\u8f6c\u6362\u65e5\u671f\u683c\u5f0f\u63d2\u56fe\" \/><\/p>\n<p><strong>Oracle \u4e2d\u5982\u4f55\u8f6c\u6362\u65e5\u671f\u683c\u5f0f<\/strong><\/p>\n<p>\u5728 Oracle \u4e2d\uff0c\u53ef\u4ee5\u8f7b\u677e\u5730\u4f7f\u7528 TO_CHAR() \u51fd\u6570\u5c06\u65e5\u671f\u8f6c\u6362\u4e3a\u4e0d\u540c\u7684\u683c\u5f0f\u3002<\/p>\n<p><strong>\u8bed\u6cd5\uff1a<\/strong><\/p>\n<pre>TO_CHAR(date_expression, 'format_mask')<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u53c2\u6570\uff1a<\/strong><\/p>\n<ul>\n<li> <strong>date_expression\uff1a<\/strong>\u8981\u8f6c\u6362\u7684\u65e5\u671f\u8868\u8fbe\u5f0f\u3002<\/li>\n<li> <strong>format_mask\uff1a<\/strong>\u6307\u5b9a\u65e5\u671f\u7684\u8f93\u51fa\u683c\u5f0f\u7684\u683c\u5f0f\u8499\u7248\u3002<\/li>\n<\/ul>\n<p><strong>\u683c\u5f0f\u8499\u7248\uff1a<\/strong><\/p>\n<table>\n<thead>\n<tr>\n<th>\u683c\u5f0f\u5b57\u7b26<\/th>\n<th>\u63cf\u8ff0<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>YYYY<\/td>\n<td>\u56db\u4f4d\u6570\u5e74\u4efd<\/td>\n<\/tr>\n<tr>\n<td>YY<\/td>\n<td>\u4e24\u4f4d\u6570\u5e74\u4efd<\/td>\n<\/tr>\n<tr>\n<td>MM<\/td>\n<td>\u4e24\u4f4d\u6570\u6708\u4efd<\/td>\n<\/tr>\n<tr>\n<td>DD<\/td>\n<td>\u4e24\u4f4d\u6570\u65e5\u671f<\/td>\n<\/tr>\n<tr>\n<td>HH<\/td>\n<td>24 \u5c0f\u65f6\u5236\u5c0f\u65f6<\/td>\n<\/tr>\n<tr>\n<td>hh<\/td>\n<td>12 \u5c0f\u65f6\u5236\u5c0f\u65f6<\/td>\n<\/tr>\n<tr>\n<td>MI<\/td>\n<td>\u5206\u949f<\/td>\n<\/tr>\n<tr>\n<td>SS<\/td>\n<td>\u79d2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u5c06\u65e5\u671f &#8216;2023-03-08&#8242; \u8f6c\u6362\u4e3a &#8217;08-03-2023&#8217; \u683c\u5f0f\uff1a<\/p>\n<pre>SELECT TO_CHAR('2023-03-08', 'DD-MM-YYYY') FROM dual;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8f93\u51fa\uff1a<\/p>\n<pre>08-03-2023<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5c06\u65e5\u671f &#8216;2023-03-08 10:30:05&#8217; \u8f6c\u6362\u4e3a &#8216;2023-03-08 10:30 AM&#8217; \u683c\u5f0f\uff1a<\/p>\n<pre>SELECT TO_CHAR('2023-03-08 10:30:05', 'YYYY-MM-DD hh:mi AM') FROM dual;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8f93\u51fa\uff1a<\/p>\n<pre>2023-03-08 10:30 AM<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<ul>\n<li>\u5982\u679c format_mask \u4e2d\u4e0d\u5b58\u5728\u67d0\u4e9b\u683c\u5f0f\u5b57\u7b26\uff0c\u5219\u76f8\u5e94\u7684\u90e8\u5206\u5c06\u4ece\u8f93\u51fa\u4e2d\u7701\u7565\u3002<\/li>\n<li>format_mask \u4e2d\u53ef\u4ee5\u5305\u542b\u5176\u4ed6\u5b57\u7b26\uff0c\u4f8b\u5982\u8fde\u5b57\u7b26\u548c\u659c\u6760\uff0c\u4ee5\u5b9a\u4e49\u8f93\u51fa\u7684\u5e03\u5c40\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u8f6c\u6362\u65e5\u671f\u683c\u5f0f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 oracle \u4e2d\uff0c\u53ef\u4f7f\u7528 to_char() \u51fd\u6570\u8f6c\u6362\u65e5\u671f\u683c\u5f0f\uff0c\u8bed\u6cd5\u4e3a\uff1ato_char(date_expression, &#8216;format_mask&#8217;)\u3002\u53c2\u6570 date_expression \u6307\u5b9a\u8981\u8f6c\u6362\u7684\u65e5\u671f\u8868\u8fbe\u5f0f\u3002\u683c\u5f0f\u8499\u7248 format_mask \u6307\u5b9a\u8f93\u51fa\u683c\u5f0f\uff0c\u5176\u4e2d yyyy \u4ee3\u8868\u56db\u4f4d\u6570\u5e74\u4efd\uff0cmm \u4ee3\u8868\u4e24\u4f4d\u6570\u6708\u4efd\uff0cdd \u4ee3\u8868\u4e24\u4f4d\u6570\u65e5\u671f\uff0chh \u4ee3\u8868 12 \u5c0f\u65f6\u5236\u5c0f\u65f6\uff0cmi \u4ee3\u8868\u5206\u949f\uff0css \u4ee3\u8868\u79d2\u3002\u4f8b\u5982\uff0c\u5c06\u65e5\u671f &#8216;2023-03-08&#8242; \u8f6c\u6362\u4e3a &#8217;08-03-2023&#8217; \u683c\u5f0f\uff1ato_char(&#8216; Oracle \u4e2d\u5982\u4f55\u8f6c\u6362\u65e5\u671f\u683c\u5f0f \u5728 Oracle \u4e2d\uff0c\u53ef\u4ee5\u8f7b\u677e\u5730\u4f7f\u7528 TO_CHAR() \u51fd\u6570\u5c06\u65e5\u671f\u8f6c\u6362\u4e3a\u4e0d\u540c\u7684\u683c\u5f0f\u3002 \u8bed\u6cd5\uff1a TO_CHAR(date_expression, &#8216;format_mask&#8217;) \u767b\u5f55\u540e\u590d\u5236 \u53c2\u6570\uff1a date_expression\uff1a\u8981\u8f6c\u6362\u7684\u65e5\u671f\u8868\u8fbe\u5f0f\u3002 format_mask\uff1a\u6307\u5b9a\u65e5\u671f\u7684\u8f93\u51fa\u683c\u5f0f\u7684\u683c\u5f0f\u8499\u7248\u3002 \u683c\u5f0f\u8499\u7248\uff1a \u683c\u5f0f\u5b57\u7b26 \u63cf\u8ff0 YYYY \u56db\u4f4d\u6570\u5e74\u4efd YY \u4e24\u4f4d\u6570\u5e74\u4efd MM \u4e24\u4f4d\u6570\u6708\u4efd DD \u4e24\u4f4d\u6570\u65e5\u671f HH 24 \u5c0f\u65f6\u5236\u5c0f\u65f6 hh 12 \u5c0f\u65f6\u5236\u5c0f\u65f6 MI [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-5312","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5312","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=5312"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5312\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}