阿恒

导航

timestamp格式化

用惯了sysdate对于timestamp有点不习惯,但后者对时间的精确度更高,这里只是记录下对格式化得到timestamp时间,
在oracle手册中

The following example converts a character string to a timestamp:

SELECT TO_TIMESTAMP ('1999-12-01 11:00:00', 'YYYY-MM-DD HH:MI:SS')
   FROM DUAL;

TO_TIMESTAMP('1999-12-0111:00:00','YYYY-MM-DDHH:MI:SS')
-----------------------------------------------------------
01-DEC-99 11.00.00.000000000 AM
这样的话只能格式化得到的时间是上午时间,要得到下午数据可以稍微改下如下

The following example converts a character string to a timestamp:

SELECT TO_TIMESTAMP ('1999-12-01 11:00:00', 'YYYY-MM-DD HH24:MI:SS')
   FROM DUAL;

TO_TIMESTAMP('1999-12-01 11:00:00','YYYY-MM-DD HH24:MI:SS')
-----------------------------------------------------------
01-DEC-99 11.00.00.000000000 AM

posted on 2009-09-07 16:02  阿恒  阅读(2568)  评论(0编辑  收藏  举报