timestamp時間格式
阿新 • • 發佈:2017-05-07
相互轉換 class 標識 0.00 app sda log 時間戳 to_date
時間戳(timestamp),通常是一個字符序列,唯一地標識某一刻的時間。
時間戳是指格林威治時間1970年01月01日00時00分00秒(北京時間1970年01月01日08時00分00秒)起至現在的總秒數。
原格式(timestamp):01-1月 -00 02.30.00.000000000 下午
轉換成 to_char 格式:‘yyyy-MM-dd HH24:mi:ss‘
sql語句:select to_char(cast(cast(timestamp as timestamp1) as date), ‘yyyy-MM-dd HH24:mi:ss‘) as timestamp2 from 表名;
date和timestamp之間的相互轉換可以通過
to_char來轉換timestamp——>date:
1 select to_date(to_char(systimestamp,‘yyyy-mm-dd hh24:mi:ss‘),‘yyyy-mm-dd hh24:mi:ss‘) from dual
date ——>timestamp:
1 select to_timestamp(to_char(sysdate,‘yyyy-mm-dd hh24:mi:ss‘),‘yyyy-mm-dd hh24:mi:ss‘) from dual:
timestamp時間格式