select to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss') from dual; --顯示當前時間 2017 - 04 - 24 18 :42 :17 select trunc(sysdate, 'year') from dual; --截取到年(本年的第一天) 2017 / 1 / 1 select trunc(sysdate, 'q') from dual; --截取到季度(本季度的第一天) 2017 / 4 / 1 select trunc(sysdate, 'month') from dual; --截取到月(本月的第一天) 或select trunc(sysdate, 'mm') from dual; --截取到月(本月的第一天) 2017 / 4 / 1 select trunc(sysdate, '') from dual; 空 select to_char(trunc(sysdate), 'yyyymmdd hh24:mi:ss') from dual; --默認截取到日(當日的零點零分零秒) 20170424 00 :00 :00 select trunc(sysdate - 1, 'w') from dual; -- 離當前時間最近的週四,若當天爲週四則返回當天,不然返回上週四 2017 / 4 / 22 select trunc(sysdate, 'ww') from dual; --截取到上週末(上週週六) 2017 / 4 / 23 select trunc(sysdate, 'day') from dual; --截取到周(本週第一天,即上週日) 2017 / 4 / 23 select trunc(sysdate, 'iw') from dual; --本週第2天,即本週一 2017 / 4 / 24 select to_char(trunc(sysdate, 'dd'), 'yyyymmdd hh24:mi:ss') from dual; --截取到日(當日的零點零分零秒) 20170424 00 :00 :00 select trunc(sysdate, 'hh24') from dual; --截取到小時(當前小時,零分零秒) 2017 / 4 / 24 18 :00 :00 select trunc(sysdate, 'mi') from dual; --截取到分(當前分,零秒) 2017 / 4 / 24 18 :44 :00 select trunc(sysdate, 'ss') from dual; --報錯,沒有精確到秒的格式 報錯:精度說明符錯誤