I am trying to create a function that can subtract between 2 dates but I am having some issues:
Firstly with the storing of the date, and secondly with the function.
Here is my code for storing the date in to a table:
CREATE TABLE car_info
(
car_id NUMBER(4)
arrival DATE,
departure DATE
......
)
here I have saved the arrival/departure times as DATES. Ideally I will want it in the format of dd-mon-yyy-hh-mm-ss
This is where I encounter my first problem:
INSERT INTO car_info
VALUES('0001', to_date('12-jun-2006 06:00:01'), to_date('14-jun-2006 09:00:01')
From the research I have done, this seems correct?
however if I do a SELECT * FROM car_info, this is the result:
car_id arrival_date departure_date
1 12-jun-2006 14-jun-2006
Does anyone know why it is not displaying the result as a full date and time?
To stop this post getting too full of information, once I have this problem solved I will post my issues with the function.
Thanks for any help
kihd regards, Darren
Second part of question has been moved to Oracle sql – date subtraction within a function
DATE in Oracle is a point in time, it is not stored with a format. A format is chosen when the date is displayed so that it can be understood by humans.
DATE by default will be displayed as per your NLS_DATE_FORMAT setting. You can change this setting with the following command:
You could also ask for an explicit format by using TO_CHAR in your query: