SQL date query problem with century/ year
We have an oracle database with about 6 million records. There is a date field called Entered Date that ranges from 1985 to the present.
The majority of these records were entered prior to Jan 1 2000.
If I run a query like
select count(*) from (tablename) where entered_date < '01-JAN-00' I get 0
if I do
select count(*) from (tablename) where entered_date < '31-DEC-99' I get 0
BUT IF I DO
select count(*) from (tablename) where entered_date < '01-JAN-00' I get 6 million records
or
select count(*) from TREASURY.ctrc where entrydate > '31-DEC-99' I get 6 million records
I've tried the same queries using 4 digit years but get the same results; it thinks that 2000 is the less than 1999
How do I get around this?
thanks