Currently I\'m using MyTimeStampField-TRUNC(MyTimeStampField)
to extract the time part from a timestamp column in Oracle.
SELECT CURRENT_TIMEST
select TO_DATE(TO_CHAR(SYSDATE,'hh24:mi:ss'),'hh24:mi:ss') from dual
This gives the timestamp for 1hour less than the actual.
This may help:
Select EXTRACT(HOUR FROM (SYSDATE - trunc(sysdate)) DAY TO SECOND ) From dual;
select hour(CURRENT_TIMESTAMP)
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.
I think the method in question is shorter and faster than in both answers. Cause it involves just two math operations and no complex parsing, formatting and conversion.
You want just date then use
to_char(cast(SYSDATE as date),'DD-MM-YYYY')
and if you want just time then use
to_char(cast(SYSDATE as date),'hh24:mi:ss')
the parameters are making all the changed
'DD-MM-YYYY'
and
'hh24:mi:ss'