The default display format of SQL*PLUS is DD-MON-YY, but the following statement retrieves nothing:
SQL> select ename,hiredate from emp where hiredate = '23-JAN-82'; no rows selectedThe following works properly:
SQL> select ename,hiredate from emp where hiredate = '23-JAN-1982'; ENAME HIREDATE ---------- --------- MILLER 23-JAN-82What causes that result?
The problem lies in the fact that how Oracle handles dates in your query is different than how SQL*Plus displays the date on the screen. Your second query worked just fine. You can determine what your date format is for your session by typing the following at the SQL*Plus prompt, "show parameter nls_date_format". The NLS_DATE_FORMAT parameter value shown is the database default. Looking at your second query, I'd bet that your NLS_DATE_FORMAT is 'DD-MON-YYYY' or 'DD-MON-RRRR'. You can change this format for your session with the ALTER SESSION SET NLS_DATE_FORMAT='format_mask' command. To change how SQL*Plus displays the date output, you'll need to convert the column with the TO_CHAR function.
For More Information
- What do you think about this answer? E-mail the editors at editor@searchDatabase.com with your feedback.
- The Best Oracle Web Links: tips, tutorials, scripts, and more.
- Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
Dig Deeper on Oracle database design and architecture
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.