date和timestamp型別之間的轉換

花花蘑菇發表於2016-11-10
date型別轉換為timestamp型別:
SQL> select to_timestamp('2006-01-01 12:10:10.1','yyyy-mm-dd hh24:mi:ss.ff') From dual;
TO_TIMESTAMP('2006-01-0112:10:
--------------------------------------------------------------------------------
01-1月 -06 12.10.10.100000000 下午

timestamp型別轉換為date型別
SQL> select systimestamp from dual;
SYSTIMESTAMP
--------------------------------------------------------------------------------
10-11月-16 07.00.27.791000 下午 +08:00

SQL> select systimestamp+0 as a from dual;
A
-----------
2016/11/10

SQL> select to_char(systimestamp,'yyyy-mm-dd hh24:mi:ss') from dual;
TO_CHAR(SYSTIMESTAMP,'YYYY-MM-
------------------------------
2016-11-10 18:59:57

SQL> select cast(systimestamp as date) from dual;
CAST(SYSTIMESTAMPASDATE)
------------------------
2016/11/10 19:02:02

SELECT to_char(to_date(m.ma_datetime,'yyyy-mm-dd hh24:mi:ss'),'yyyyMMdd') FROM my_task m;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28497416/viewspace-2128271/,如需轉載,請註明出處,否則將追究法律責任。

相關文章