Strange behaviour when filtering by date in Oracle -


i'm on oracle database, following query:

select codi_belf, data_elab,id_inte,anno mimsspam_tab id_inte = 504; 

retrieves 6 records

 e924    05-ago-15   504 2015 d458    05-ago-15   504 2015 d458    05-ago-15   504 2015 b275    05-ago-15   504 2015 e924    05-ago-15   504 2015 b275    05-ago-15   504 2015 

where "data_elab" field of type date , ago italian locale aug.

i try filter date this:

select codi_belf, data_elab,id_inte,anno  mimsspam_tab id_inte = 504  , data_elab = to_date('05/08/2015','dd/mm/yyyy'); 

and no results..

moreover if filter way:

select codi_belf, data_elab,id_inte,anno   mimsspam_tab id_inte = 504  , to_char(data_elab,'dd/mm/yyyy')='05/08/2015'; 

i got 6 records back!

shouldn't 2 ways of filtering equivalent? why aren't? , why first eats 6 records? depend on weird configuration of oracle installation i'm querying to?

what see in first query database default date format, determined nls parameters. date field contains time information, don't see it.

in second query, when use to_date(), convert string date , don't provide time information, 00:00:00 time part of date. comparing field (which includes time information) result in no match.

in third query, when use to_char(), convert date field string doesn't include time information. comparing literal string, matched records.

try think of date field binary information, not character string. try not rely on database default parameters.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -