timestamp时间格式

时间戳(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:

posted on 2017-05-07 09:07  西城墨客  阅读(18256)  评论(0编辑  收藏  举报

导航