how to show only the time in oracle?

笑着哭i 提交于 2021-01-27 05:09:19

问题


I have table that has date field. When I run a query, I see this:

01/10/2009 22:10:39

How can I retrieve only the time (IE: 22:10:39)


回答1:


you can try this:

SELECT TO_CHAR(yourval, 'DD-MON-YYYY HH:MI:SS') FROM yourtable;
SELECT TO_CHAR(yourval, 'HH:MI:SS') FROM yourtable;

Edit: as @steven pointed out, to have 24 hours style use

SELECT TO_CHAR(yourval, 'HH24:MI:SS') FROM yourtable;



回答2:


You need the format HH24, since HH is only a 12 hour date.

select to_char(SYSDATE, 'HH24:MI:SS') from dual

select to_char(YourDateColumn, 'HH24:MI:SS') from YourTable



回答3:


SELECT TO_CHAR (SYSDATE, 'hh:mi:ss') FROM DUAL




回答4:


SELECT TO_CHAR(DATE_COLUMN,'HH24:MI:SS') from TABLE;



来源:https://stackoverflow.com/questions/1568406/how-to-show-only-the-time-in-oracle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!