开发者

How To Format Timestamp

I have col1 in myTable which is varchar, and I have to insert here timestamp eg:- 09-MAY-11 10.23.12.0000 AM.

Now please tell me:

  • How to insert into myTable with taki开发者_StackOverflow中文版ng sysdate in above format...
  • How to retrieve data from col1 in tha same timestamp format..


INSERT:

insert into myTable (col1) VALUES (to_char(systimestamp, 'dd-mon-yyyy hh.mi.ss.ff4 AM') );

SELECT:

select to_timestamp(col1, 'dd-mon-yyyy hh.mi.ss.ff4 AM')  from myTable ;

But it is much better to store the data directly as a timestamp. Then you can compare the values ​​or modify them directly.

create table myTable1( col1 timestamp default systimestamp);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜