Gold
Gold

Reputation: 62484

how to show only the time in oracle?

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)

Upvotes: 6

Views: 44702

Answers (4)

Haid
Haid

Reputation: 111

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

Upvotes: 1

Amirshk
Amirshk

Reputation: 8258

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;

Upvotes: 16

Steven
Steven

Reputation: 13769

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

Upvotes: 5

Henry Gao
Henry Gao

Reputation: 4936

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

Upvotes: 4

Related Questions