Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Problem with query with dates in where clause
Shiva,
Your first query is going to check the full date including the time portion .
If the dates for hiredate stored in the table are truncated so that the time portion is 00:00:00 for all the records then you can use:
Select * from Emp
where hiredate = trunc(sysdate);
If the dates contain time info, then use
Select * from Emp
where trunc(hiredate) = trunc(sysdate);
Keep in mind that this query won't use an existing
index on hiredate, unless you're on 8i and have
created a function based index which truncates the
date on the hiredate column.
For the second query, I suspect that your NLS_DATE_FORMAT is set to dd-mon-yy so you're actually looking for dates equal to 19-JUN-1900 instead of 2000
You can verify this by checking NLS_SESSION_PARAMETERS or alter the session before running the query: ALTER SESSION SET NLS_DATE_FORMAT='DD-MON-RR'; HTH,
![]() |
![]() |