开发者

how to show only the time in oracle?

开发者 https://www.devze.com 2022-12-09 01:24 出处:网络
I have table that has date field.When I r开发者_C百科un a query, I see this: 01/10/2009 22:10:39

I have table that has date field. When I r开发者_C百科un a query, I see this:

01/10/2009 22:10:39

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


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;


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


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


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

0

精彩评论

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

关注公众号