Oracle時間格式與整型格式相互轉化,oracle時間格式整型

來源:互聯網
上載者:User

Oracle時間格式與整型格式相互轉化,oracle時間格式整型

        若Oracle資料庫時間欄位設定為“NUMBER”類型,查詢時間列時會以數值的形式展現,像“1241450728000”樣式,不具備可讀性;同時若以“2009/5/4 15:25:28”樣式update時間,則會提示“ORA-01722:invalid number”,無法更新。

        這時,就需要我們對此進行格式轉化,樣本如下:

--date轉long樣本select sysdate,(sysdate- to_date('1970-01-01','yyyy-mm-dd'))* 24*60*60*1000 as 整型格式 from dual;--long轉dateselect  to_date('1970-01-0100:00:00','yyyy-mm-dd hh24:mi:ss') + 1241450728000/1000/24/60/60 from  dual;


相關文章

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.