Good evening.
I have created a database with ORACLE SQL Developer and am having a small problem.
In the RENTING table that I have created something like this:
CREATE TABLE RENTING (cAFM NUMBER NOT NULL, vPlateNumber VARCHAR (7) NOT NULL, OutDate DATE, InDate DATE, PRIMARY KEY (cAFM, vPlateNumber, OutDate), FOREIGN KEY (cAFM) REFERENCES CUSTOMER (cAFM), FOREIGN KEY (vPlateNumber) REFERENCES VEHICLE (vPlateNumber));
I am trying to enter the following data:
cAFM = 10001, vPlateNumber = ‘XKO5434’, OutDate = ’13 / 07/2020 09:30 ‘, InDate = ’18 / 07/2020 08:00’
I type these commands:
INSERT INTO RENTING (cAFM, vPlateNumber, OutDate, InDate) VALUES (10001, 'XKO5434', TO_DATE ('13 / 07/2020 09:30 ',' DD / MM / YYYY HH24: MI '), TO_DATE ('18 / 07/2020 08:00', 'DD / MM / YYYY HH24: MI '));
I get these results:
CAFM VPLATENUMBER OUTDATE INDATE 10001 XKO5434 13/07/20 18/07/20
without displaying the hours I entered (’09: 30 ‘and ’08: 00’).
If anyone could help me I would be grateful.
Advertisement
Answer
Do this:
SELECT TO_CHAR(indate, 'YYYY-MM-DD HH24:MI:SS') FROM RENTING
It will be fine; the time is there, but your query tool isn’t showing it because it’s formatting to just the date part
https://dbfiddle.uk/?rdbms=oracle_18&fiddle=a0c267946bd451b28edcaeab5e64770d
As an aside, when presenting strings for parsing to other forms, strive to be accurate; the spacing of your date strings does not match the spacing of your format string