Professional Documents
Culture Documents
The DATE data type stores the year (which includes the century), the month, the
day, the hours, the minutes, and the seconds.
Oracle Database has its own propriety format for storing date data. It uses fixed-
length fields of 7 bytes, each corresponding to century, year, month, day, hour,
minute, and second to store date data.
The standard(default) date format for input and output is DD-MON-YY e.g., 01-
JAN-17 which is controlled by the value of the NLS_DATE_FORMAT parameter.
Important :-
So even if you store as below while querying we can see as 01-MAR-85. But
internally hours,min,sec are also get stored in Date datatype column.
For example, to display the current system date in a specific format, you use the
TO_CHAR() function as follows:
SELECT
TO_CHAR( SYSDATE, 'FMMonth DD, YYYY' )
FROM
dual;
The output is: August 1, 2017
The language that the TO_CHAR()function uses for displaying the month name is
controlled by the NLS_DATE_LANGUAGE parameter:
SELECT
value
FROM
V$NLS_PARAMETERS
WHERE
parameter = 'NLS_DATE_LANGUAGE';
Now, you can execute the TO_CHAR() function again to see the effect:
SELECT
TO_CHAR( SYSDATE, 'FMMonth DD, YYYY' )
FROM
dual;
Output:- Août 1, 2017
To convert date values that are not in the standard format, you use the
TO_DATE() function with a format string.
SELECT
TO_DATE( 'August 01, 2017', 'MONTH DD, YYYY' )
FROM
dual;
Date literals
Besides using the TO_DATE() function , you can specify a DATE value as a string
literal using the following syntax:
insert into test2 values(DATE '2017-11-01');
Oracle TIMESTAMP
The TIMESTAMP data type allows you to store date and time data including year,
month, day, hour, minute and second.
In addition, it stores the fractional seconds, which is not stored by the DATE data
type.
digits in the fractional part of the SECOND field ranges from 0 to 9, meaning that
you can use the TIMESTAMP data type to store up to nanosecond.
SELECT
value
FROM
V$NLS_PARAMETERS
WHERE
parameter = 'NLS_TIMESTAMP_FORMAT';
Output -> DD-MON-RR HH.MI.SSXFF AM