updated_date = 08-Jun-2010;
I have a query like this
select * from asd whre updated_date <= todate('08-Jun-2010', 'dd-MM-yy');
but I am not getting any results. it only works if todate is 09-Jun-2010…
i.e. my equalto operator is not working properly.
why is it like that?
In Oracle a DATE is a point in time. It always has a time component with a precision to the second.
todate('08-Jun-2010', 'dd-Mon-yyyy')is in Oracle the same astodate('08-Jun-2010 00:00:00', 'dd-Mon-yyyy hh24:mi:ss'). So if you select rows up to that date you won’t get any row on that day with a time component not equal to00:00.If you want to select all the rows up to and including
08-JUN-2010, I would suggest using:or
Note – I corrected your date format: you need to use
MONif you want to use the abbreviated month name. I would suggest usingMMinstead, so that you won’t get error when someone changes its client settings (NLS_DATE_LANGUAGE). Also prefer the use ofYYYYinstead ofYY.