甲骨文如何输出日期和时间? [英] Oracle. How to output date and time?
本文介绍了甲骨文如何输出日期和时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的访问表如下:
insert into Visit
values(12, to_date('19-JUN-13', 'dd-mon-yy'), to_date('19-JUN-13 12:00 A.M.' , 'dd-mon-yy hh:mi A.M.'));
insert into Visit
values(15, to_date('20-JUN-13', 'dd-mon-yy'), to_date('20-JUN-13 02:00 A.M.' , 'dd-mon-yy hh:mi A.M.'));
insert into Visit
values(18, to_date('21-JUN-13', 'dd-mon-yy'), to_date('21-JUN-13 10:30 A.M.' , 'dd-mon-yy hh:mi A.M.'));
当我尝试查询它:
select * from Visit
我得到:
When i try to query it:
select * from Visit
i get:
SQL> select * from visit;
SLOTNUM DATEVISIT ACTUALARRIVALTIME
---------- --------- ------------------------------
12 19-JUN-13 19-JUN-13
15 20-JUN-13 20-JUN-13
18 21-JUN-13 21-JUN-13
SQL> spool off;
如何到达时间不在?
推荐答案
您还可以设置适用于所有日期的格式:
You can also set a format that applies to all dates like this:
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH:M:SS PM';
这样,您的原始查询将以您之前的格式输出日期,而不使用 TO_CHAR
。要恢复到通常的默认格式,只需执行以下操作:
That way, your original query would output the dates in the format you're after, without using TO_CHAR
. To set back to the usual default format, just do this:
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-RR';
这篇关于甲骨文如何输出日期和时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文