Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Problem with query with dates in where clause

Re: Problem with query with dates in where clause

From: A. Bardeen <abardeen1_at_yahoo.com>
Date: Mon, 19 Jun 2000 01:23:38 -0700 (PDT)
Message-Id: <10533.109678@fatcity.com>


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,


Do You Yahoo!? Received on Mon Jun 19 2000 - 03:23:38 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US