Select oracle date column using C #

I am trying to select data from my Oracle BY DATE database using C #. However, I always get an empty dataset, although the same query string works fine in Oracle SQL Developer

String Query = "Select position_date from position";
OracleDataAdapter adapter = new OracleDataAdapter(Query, ocon); 
adapter.Fill(ds, "table"); //where ds is a dataset 
PrintDataSet(ds);

returns

3/8/2011 12:00:00 AM.... and more

However, when I change my request below, there is no way out!

String Query = "Select position_date from position 
where to_char(position_date, 'mm-dd-yyyy') = '05-17-2012'"

This query works fine in oracle sql developer. I also tried trunc (sysdate) but nothing works !: (

+3
source share
2 answers
select * from position where trunc(position_date) = to_date('05-17-2012', 'mm-dd-yyyy')

worked.

Thank.

+1
source

If your dates do not have a time component (and if so, then guarantee it with a check constraint), then:

Select position_date
from   position 
where  position_date = date '2012-05-17'

Otherwise:

Select position_date
from   position 
where  position_date >= date '2012-05-17' and 
       position_date <  date '2012-05-17' + 1
0
source

All Articles