tags:

views:

74

answers:

2

Actually i' am using MyTimeStampField-TRUNC(MyTimeStampField) to extract the time part from an timestamp column in Oracle.

SELECT CURRENT_TIMESTAMP-TRUNC(CURRENT_TIMESTAMP) FROM DUAL

this return

+00 13:12:07.100729

this work ok for me, to extract the time part from an timestamp field, but i' m wondering if exist a better way (may be using an built-in function of ORACLE) to do this?

Thanks.

+3  A: 

What about EXTRACT() ?

Frank Heikens
@Frank if use the extract function, should be wrote something like `SELECT EXTRACT(HOUR FROM CURRENT_TIMESTAMP) || ':' ||EXTRACT(MINUTE FROM CURRENT_TIMESTAMP)|| ':' ||EXTRACT(SECOND FROM CURRENT_TIMESTAMP) FROM DUAL;` this is more efficient wich the method i actually use?
RRUZ
+1  A: 

You could always do something like:

select TO_DATE(TO_CHAR(SYSDATE,'hh24:mi:ss'),'hh24:mi:ss') from dual

I believe this will work with timestamps as well.

LBushkin