Convert a Number to time in Oracle

Hi,

In a oracle database table i have a colum that gives the value from 0 to 2359. I want to convert Number to time in Oracle. Any i dea on the query for this.

I have tried

SELECT TO_CHAR('2342','HH:MI') "Time"

FROM dual;

but it is not functioning.

Thanks

[308 byte] By [javaqueuea] at [2007-11-27 11:48:22]
# 1

I think u have to get those 4 numbers from database, then use date format class to parse it correctly

ksinghaniaa at 2007-7-29 18:18:51 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

Yes ,

Thats true, But how to convert that Fetched column value to Time ?

Thanks

javaqueuea at 2007-7-29 18:18:51 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

Don't store the time as a Number in Oracle. Store the time as a Timestamp in Oracle. That way you can use convential Java code to get and put the time.

WorkForFooda at 2007-7-29 18:18:51 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

The Number that i want to convert to Time is of the columns of the same table and depending on its value, i want to display it as Time.

Thanks,

javaqueuea at 2007-7-29 18:18:51 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5

> The Number that i want to convert to Time is of the

> columns of the same table and depending on its value,

> i want to display it as Time.

> Thanks,

Well it sounds like you certainly have no clue what you are doing whatsoever. I predict a bright future for you.

Here's some advice. If the column should have a date or time in it then use a date or time type column. If you are creating a variable data type column then ASAP get a book on SQL before you **** things up worse then you have.

There is no great mystery here. There is the right way (as suggested by WorkForFood) and there is the wrong way (whatever you are doing). So do what WorkForFood told you or just go away because nobody cares to help make a disaster.

cotton.ma at 2007-7-29 18:18:51 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...