Filtering by difference in dates in where SQL Oracle -


i have script collects data many different tables, , returns results, script not written me , has 1000+ code lines. simplify:

select         date_of_opening,        ...<many other columns>        <some other sub queries>; 

as returns whole set of data, thought limit it, opened in period of 30 days, have tried:

select *        (select                date_of_opening,               ...<many other columns>                      <some other sub queries>) date_of_opening - to_date('23.01.2011','dd.mm.yyyy') between (-30) , (-1) ; 

which resulted in

ora-00932: inconsistent datatypes: expected char got date.

however if try same query in select, show difference correct one:

select         date_of_opening,        date_of_opening - to_date('23.01.2011','dd.mm.yyyy') difference,        ...<many other columns>        <some other sub queries>; 

assuming example date_of_opening 31.12.2010 difference -23

i have tried first calculate difference , filter in where difference between (-30) , (-1) got

ora-00932: inconsistent datatypes: expected number got date

datatype of past_of_opening date

what method can use filter results, or cause of such behavior?

a period of 30 days might be:

where date_of_opening  between (to_date('23.01.2011','dd.mm.yyyy')-30) , (to_date('23.01.2011','dd.mm.yyyy'))  

assuming date_of_opening indeed date.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -