How to alter a field in oracle to save only the time

1

I have the following table created in oracle but when I created the time I put it as a date type and I want to change it to a data type that only saves the time in the field VUE_HORA_SALIDA

    
asked by Juan .M 30.07.2017 в 06:26
source

1 answer

1

There is no data type hour (hour), what you can do is define the column as DATE (store the date and time).

When you need the time you use the HOUR() function that returns the time (in 24 hours format) of a valid date.

SELECT HOUR(campo) FROM tabla;

When you need the date you use the TO_CHAR() function that returns a string that contains the date according to the specified format.

SELECT TO_CHAR(campo, "DD-MM-YYYY") FROM tabla;

It is not necessary to have a field to store the time ( VUE_HORA_SALIDA ) and another one for the date ( VUE_FECHA_SALIDA ), but they can be grouped in a single field that is called VUE_SALIDA . The same goes for VUE_HORA_LLEGADA and VUE_FECHA_LLEGADA .

    
answered by 30.07.2017 в 06:47