Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

oracle date field not comparing properly with to_date function

807001Oct 21 2010 — edited Oct 22 2010
Hi, i'm facing a very weird problem. I'm triyng to retrieve a range of records in between two dates. However, it doesn't seem to understand. What am i doing wrong?

let's say my table (MYRECORD) has this (where id is varchar and date is DATE and not timestamp) :

ID DATE
---- ----------
1 22-JAN-08
2 22-JAN-08
3 21-JAN-10
4 11-FEB-10
5 11-FEB-10


So, let's say iwanna get the records from 21st Jan 2010 :

select
date as ori_date from MYRECORD where
date = to_date('21/01/2010','DD/MM/YYYY')

1.)
it is not returning any record at all. I'm having problems with between dates and the to_date function as well,
so i'm trying to get the 'equal' part working first. I can't use to_char because at the end of the day,
i need to compare between dates.

what am i doing wrong? has this got anything to do with what kind of format is set up on the oracle server?


running :
SELECT value FROM v$nls_parameters WHERE parameter ='NLS_DATE_FORMAT'

returns DD-MON-RR

2.) how do we compare dates from the table according to our own specified format from our passed string? I only have READONLY access to this database
so i can't set anything up.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 19 2010
Added on Oct 21 2010
10 comments
14,690 views