Oracle sql 合并分解時間欄位

來源:互聯網
上載者:User

最近在做項目,有這麼一個情況,目前資料庫上面有3個欄位,year,month,day分別表示年,月,日,現在我需要把他們合并到一起,可以使用這種sql文法

  1. to_date(y.year||y.month||y.day,'yyyy-mm-dd')   

這樣就可以把他們3個合并到一個欄位上面來了,那麼我們也可以把他們分解開,像這樣

  1. to_char(t.collect_date,'yyyy') as year,to_char(t.collect_date,'mm') as month,to_char(t.collect_date,'dd') as day  

相關文章

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.