Default Date Format

The default date format is specified in the NLS_DATE_FORMAT database parameter.


SQL> ALTER SESSION SET NLS_DATE_FORMAT = 'MONTH-DD-YYYY';

Session altered.

SQL>

A session is started when you connect to a database and is ended when you disconnect.


CREATE TABLE EMP (EMPNO NUMBER(4) NOT NULL,
                      ENAME VARCHAR2(10),
                      HIREDATE DATE);

INSERT INTO EMP VALUES (1, 'SMITH', TO_DATE('17-DEC-1980', 'DD-MON-YYYY'));
INSERT INTO EMP VALUES (2, 'ALLEN', TO_DATE('20-FEB-1981', 'DD-MON-YYYY'));
INSERT INTO EMP VALUES (3, 'WARD',  TO_DATE('22-FEB-1981', 'DD-MON-YYYY'));
INSERT INTO EMP VALUES (4, 'JONES', TO_DATE('2-APR-1981',  'DD-MON-YYYY'));
INSERT INTO EMP VALUES (5, 'MARTIN',TO_DATE('28-SEP-1981', 'DD-MON-YYYY'));

SQL>
SQL> SELECT hiredate
  2  FROM emp;

HIREDATE
-----------------
DECEMBER -17-1980
FEBRUARY -20-1981
FEBRUARY -22-1981
APRIL    -02-1981
SEPTEMBER-28-1981

SQL>

Use the new date format when inserting.


SQL> INSERT INTO emp(empno, ename, hiredate) VALUES (1, 'Fred','MARCH-15-1970');


1 row created.

SQL>
Home »
Oracle »
Data types » 

Date:
  1. Date
  2. Default Date format
  3. Date literal and Date keyword
  4. Date and Time
  5. Default Date Format
Related: