oracle trunc 函數處理日期格式,

來源:互聯網
上載者:User

標籤:oracle   font   trunc   logs   格式   處理   sys   否則   說明符   

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

 

oracle trunc 函數處理日期格式,

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.