9. \u83b7\u53d6\u5f53\u524d\u65f6\u95f4\u662f\u4eca\u5e74\u7684\u7b2c\u591a\u5c11\u5929<\/strong><\/div>\nselect TO_CHAR(SYSDATE,'DDD'),sysdate from dual;<\/pre>\ntrunc[\u622a\u65ad\u5230\u6700\u63a5\u8fd1\u7684\u65e5\u671f,\u5355\u4f4d\u4e3a\u5929] ,\u8fd4\u56de\u7684\u662f\u65e5\u671f\u7c7b\u578b<\/p>\n
select sysdate S1, \r\n trunc(sysdate) S2, \/\/\u8fd4\u56de\u5f53\u524d\u65e5\u671f,\u65e0\u65f6\u5206\u79d2\r\n trunc(sysdate,'year') YEAR, \/\/\u8fd4\u56de\u5f53\u524d\u5e74\u76841\u67081\u65e5,\u65e0\u65f6\u5206\u79d2\r\n trunc(sysdate,'month') MONTH , \/\/\u8fd4\u56de\u5f53\u524d\u6708\u76841\u65e5,\u65e0\u65f6\u5206\u79d2\r\n trunc(sysdate,'day') DAY \/\/\u8fd4\u56de\u5f53\u524d\u661f\u671f\u7684\u661f\u671f\u5929,\u65e0\u65f6\u5206\u79d2\r\n from dual<\/pre>\n10. \u8fd4\u56de\u65e5\u671f\u5217\u8868\u4e2d\u6700\u665a\u65e5\u671f<\/strong><\/div>\nselect greatest('2021-01-04','2022-01-04','2019-02-04') from dual; --\u7ed3\u679c\uff1a2022-01-04<\/pre>\n11. \u8ba1\u7b97\u65f6\u95f4\u5dee<\/strong><\/div>\nselect floor(to_number(sysdate-to_date('2020-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))\/365) as spanYears from dual \/\/\u65f6\u95f4\u5dee-\u5e74\r\nselect ceil(months_between(sysdate,to_date('2020-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))) as spanMonths from dual \/\/\u65f6\u95f4\u5dee-\u6708\r\nselect floor(to_number(sysdate-to_date('2020-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))) as spanDays from dual \/\/\u65f6\u95f4\u5dee-\u5929\r\nselect floor(to_number(sysdate-to_date('2020-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))*24) as spanHours from dual \/\/\u65f6\u95f4\u5dee-\u65f6\r\nselect floor(to_number(sysdate-to_date('2020-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))*24*60) as spanMinutes from dual \/\/\u65f6\u95f4\u5dee-\u5206\r\nselect floor(to_number(sysdate-to_date('2020-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))*24*60*60) as spanSeconds from dual \/\/\u65f6\u95f4\u5dee-\u79d2<\/pre>\n12. \u67e5\u627e\u6708\u7684\u7b2c\u4e00\u5929,\u6700\u540e\u4e00\u5929<\/strong><\/div>\nSELECT Trunc(Trunc(SYSDATE, 'MONTH') - 1, 'MONTH') First_Day_Last_Month, --\u6700\u540e\u4e00\u6708\u6700\u540e\u4e00\u5929\r\n Trunc(SYSDATE, 'MONTH') - 1 \/ 86400 Last_Day_Last_Month, --\u6700\u540e\u4e00\u6708\u6700\u540e\u4e00\u5929\r\n Trunc(SYSDATE, 'MONTH') First_Day_Cur_Month, --\u5f53\u524d\u6708\u7b2c\u4e00\u5929\r\n LAST_DAY(Trunc(SYSDATE, 'MONTH')) + 1 - 1 \/ 86400 Last_Day_Cur_Month --\u5f53\u524d\u6708\u6700\u540e\u4e00\u5929\r\n FROM dual;<\/pre>\n13. \u67e5\u8be2\u65f6\u95f4\u4e4b\u524d\u7684\u65f6\u95f4\uff08\u67e5\u4e4b\u540e\u628a\u51cf\u53f7\u6362\u6210\u52a0\u53f7\uff09<\/strong><\/div>\n\u5f53\u524d\u65f6\u95f4\u51cf\u53bb7\u5206\u949f\u7684\u65f6\u95f4\r\nselect sysdate,sysdate - interval '7' MINUTE from dual\r\n \r\n\u5f53\u524d\u65f6\u95f4\u51cf\u53bb7\u5c0f\u65f6\u7684\u65f6\u95f4\r\nselect sysdate - interval '7' hour from dual\r\n \r\n\u5f53\u524d\u65f6\u95f4\u51cf\u53bb7\u5929\u7684\u65f6\u95f4\r\nselect sysdate - interval '7' day from dual\r\n \r\n\u5f53\u524d\u65f6\u95f4\u51cf\u53bb7\u6708\u7684\u65f6\u95f4\r\nselect sysdate,sysdate - interval '7' month from dual\r\n \r\n\u5f53\u524d\u65f6\u95f4\u51cf\u53bb7\u5e74\u7684\u65f6\u95f4\r\nselect sysdate,sysdate - interval '7' year from dual\r\n \r\n\u65f6\u95f4\u95f4\u9694\u4e58\u4ee5\u4e00\u4e2a\u6570\u5b57\uff08\u4e5f\u5c31\u662f8\u4e2a\u5c0f\u65f6*2\u500d\uff0c16\u4e2a\u5c0f\u65f6\u4e4b\u524d\u7684\u6570\u636e\uff09\r\nselect sysdate,sysdate - 8 *interval '2' hour from dual\r\n \r\n \r\n\u83b7\u53d6\u4e03\u5929\u4e4b\u540e\u7684\u65f6\u95f4\r\nselect (sysdate + 7) from dual;\r\n \r\n\u83b7\u53d6\u524d\u4e00\u4e2a\u6708\u7684\u65f6\u95f4\uff08\u6b63\u6570\u65f6\u662f\u52a0\u6708\uff0c\u8d1f\u6570\u65f6\u4e3a\u51cf\u6708\uff09\r\nselect add_months(sysdate,-1) from dual;\r\n \r\nselect sysdate+1 from dual \u52a0\u4e00\u5929\r\nselect sysdate+1\/24 from dual \u52a01\u5c0f\u65f6\r\nselect sysdate+1\/(24*60) from dual \u52a01\u5206\u949f\r\nselect sysdate+1\/(24*60*60) from dual \u52a01\u79d2\u949f<\/pre>\n\u5230\u6b64\u8fd9\u7bc7\u5173\u4e8eOracle\u6839\u636e\u65f6\u95f4\u67e5\u8be2\u7684\u6587\u7ae0\u5c31\u4ecb\u7ecd\u5230\u8fd9\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"
\u67e5\u8be22021-01-01 \u81f3 2021-01- 02 \u7684\u6570\u636e SELECT * FROM t_table1 t […]<\/p>\n","protected":false},"author":1482,"featured_media":49103,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-251354","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/251354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1482"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=251354"}],"version-history":[{"count":4,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/251354\/revisions"}],"predecessor-version":[{"id":251360,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/251354\/revisions\/251360"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/49103"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=251354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=251354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=251354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}