Why date format is not working?

Question:

Schema: SCOTT
8.0.5 or 8.1.5 environment

WHY THIS GOING ON ?!!!!

SQL>  select ename, job,hiredate
  2   from emp
  3   where hiredate between
  4   to_date ('20-FEB-81') AND
  5   to_date ('01-MAY-81')
  6   ORDER BY hiredate
  7  /

no rows selected

SQL>  select ename, job,hiredate
  2   from emp
  3   where hiredate between
  4   to_date ('20-FEB-1981', 'DD-MM-YYYY') AND
  5   to_date ('01-MAY-1981', 'DD-MM-YYYY')
  6   ORDER BY hiredate
  7  /

ENAME      JOB       HIREDATE
---------- --------- ---------
ALLEN      SALESMAN  20-FEB-81
WARD       SALESMAN  22-FEB-81
JONES      MANAGER   02-APR-81
BLAKE      MANAGER   01-MAY-81

SQL> spool off

Answer:

If you use 2 digit Year, Oracle adds the current century as default. So
you search the dates between 2/20/2000 ad 5/01/2000
 

Hosted by www.Geocities.ws

1