ORACLE中date和timestamp的相互轉化
阿新 • • 發佈:2018-11-16
原文章地址:https://blog.csdn.net/chenlong331409178/article/details/47441025
oracle 中date型別精確可以年月日,時分秒,timestamp型別可以精確的秒一下
data轉為timstamp
data 轉為timstam可以函式to_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:10.1','YYYY-MM-DDHH24:MI:SS.FF')
---------------------------------------------------------------------------
01-1月 -06 12.10.10.100000000 下午
- 1
- 2
- 3
- 4
- 5
timestamp轉化為data
1, timestamp+0
SQL> select Systimestamp+0 FROM DUAL;
SYSTIMESTAMP+0
--------------
12-8月 -15
- 1
- 2
- 3
- 4
- 5
2, to_char的方式
SQL> Select to_char(Systimestamp,'yyyymmdd') From dual;
TO_CHAR(
--------
20150812
- 1
- 2
- 3
- 4
- 5
3,cast轉化
SQL> Select Cast(Systimestamp As Date) From dual;
CAST(SYSTIMEST
--------------
12-8月 -15