cast(systimestamp as date)也可以将timestamp转换成Date。
select cast(systimestamp as Date) from Dual; systimestamp --26-4月 -17 07.14.45. 下午 +08:00 rusult --2017/4/26 19:14:01
(timestamp-0)可以直接将timestamp类型数据转换 成Date。
select systimestamp - 0 from Dual; systimestamp --26-4月 -17 07.14.45. 下午 +08:00 rusult --2017/4/26 19:15:51
最后一种方式是用to_char,to_date,to_timestamp进行格式转换
select to_date(to_char(systimestamp, 'YYYYMMDD HH24:MI:SS'), 'YYYYMMDD HH24:MI:SS') from dual; systimestamp --26-4月 -17 07.16.47. 下午 +08:00 rusult --2017/4/26 19:17:58
2、Date–>timestamp
可以用to_char,to_date,to_timestamp进行转换。
select to_timestamp(to_char(to_date(' 12:12:12', 'YYYYMMDD HH24:MI:SS'), 'YYYYMMDD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS') from dual; Date -- 12:12:12 result --01-1月 -17 12.12.12.000000000 下午
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/230308.html原文链接:https://javaforall.net
