Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I tried To_Timestamp and other methods for SQL Developer but only this one worked fine for me.

Select To_Number(To_Char(DateTime_FieldName, 'HH24'))
    || ':' || to_number(to_char(DateTime_FieldName, 'MI'))
    || ':' ||to_number(to_char(DateTime_FieldName, 'SS'))
from TABLE_NAME

Is there a better solution to this?

share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

Assuming your goal is to generate a string representing the time (which is what the query you posted returns despite the extraneous to_number calls)

SELECT to_char( <<column_name>>, 'HH24:MI:SS' )
  FROM table_name

If you want to return a different data type, you'd need to tell us what data type you want to return. If, for example, you really want to return an INTERVAL DAY TO SECOND

SELECT numtodsinterval( <<column name>> - trunc(<<column name>>), 'day' )
  FROM table_name
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.