Hi Joachim,
we do not format the date with to_date(), the only thing we do is pass a java.sql.Date to Crystal. Crystal seems to make this to_date() with date parameters and oracle.
I will test tuesday with Oracle, but I tested with MSSQL and it I have this:
My query:
select * from myTable
where f_geb_datum < {?gebDatum}
order by f_geb_datum desc
The query I get when making a Crystal preview:
select * from myTable
where f_geb_datum < {d ‘2016-08-04’}
order by f_geb_datum desc
The query I get when using reportserver:
select * from myTable
where f_geb_datum < {d ‘2016-08-04’}
order by f_geb_datum desc
If I use “-”, then:
My query:
select * from myTable
where f_geb_datum < {?gebDatum} - 365
order by f_geb_datum desc
In Crystal:
select * from myTable
where f_geb_datum < {d ‘2016-08-04’} - 365
order by f_geb_datum desc
In reportserver:
select * from myTable
where f_geb_datum < {d ‘2016-08-04’} - 365
order by f_geb_datum desc
Reportserver only passes a java.sql.Date to CrystalReports. CrystalReports seems to create here a {d ‘2016-08-04’} for MSSQL. I guess this is the same for Oracle (Crystal would create a to_date()): I will test this tuesday.
But, whatever the result, the basic idea is that someone has to format the expression. In the postings above, we recommended doing this by hand, as we always do in dynamic lists. Here, the situation seems to be a little different, since Crystal does this instead of doing it manually. But the idea is the same.
As you see in my examples, the “- 365” works with MSSQL, I suppose this should work with Oracle too. In your examples without “- 1”, the formatting created by Crystal is correct in both cases. But something seems to be happening with the “- 1” expression. Can’t you see what exactly arrives at Oracle with select * from user_objects where created > {?PM-Datum} - 1 ? Since Oracle says: “(ORA-00932: Inkonsistente Datentypen: DATE erwartet, NUMBER erhalten)”, something must be arriving. Could you check with some profiler or similar ?
Could you try with the following (or similar) alternatives of “- 1” ?
- select * from user_objects where created > {?PM-Datum} - INTERVAL ‘1’ DAY
- select * from user_objects where created > {?PM-Datum} - NUMTODSINTERVAL(1, ‘day’)
- maybe there is some problem with the ordering: select * from user_objects where created > ( {?PM-Datum} - 1 )
- the same for: select * from user_objects where created > ( {?PM-Datum} - INTERVAL ‘1’ DAY ) and select * from user_objects where created > ( {?PM-Datum} - NUMTODSINTERVAL(1, ‘day’) )
I haven’t tested this, but maybe something is happening with “- 1”.
Best regards,
Eduardo