Why the query returns results having hire_date greater than given date?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • itiger
    New Member
    • Sep 2010
    • 12

    Why the query returns results having hire_date greater than given date?

    Code:
    SELECT last_name, TO_CHAR(hire_date, 'DD-Mon-yyyy')
    from employees
    WHERE TO_DATE(hire_date, 'DD-Mon-YYYY') < '01-Jan-1990';
    
    
    Output:
    
    LAST_NAME       TO_CHAR(HIRE_DATE,'DD-MON-YYYY')
    -------------------------------------------------- 
    King            17-Jun-1987 
    Kochhar         21-Sep-1989 
    De Haan         13-Jan-1993 
    Hunold          03-Jan-1990 
    Ernst           21-May-1991 
    Austin          25-Jun-1997
    Why the query returns rows of those employees having hire_date greater (after) '01-Jan-1990'.
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    Try this:

    Code:
    SELECT last_name, TO_CHAR(hire_date, 'DD-Mon-yyyy') 
    from employees 
    WHERE TO_DATE(hire_date, 'DD-Mon-YYYY') < 
    TO_DATE('01-Jan-1990','DD-Mon-RRRR');
    /

    Comment

    Working...