Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Problem with dates in select
Hi,
The User inputs: ColumnName, Operator (=,<,>,!=) and a Value. In SQL-Server I used this to create an SELECT-statement with the user input:
If the value is a date and the column is also date i created the following:
SELECT * FROM Objects WHERE DateDiff(day, Columnname, 'UserValue') = 0
The '=0' changes with the choosen operator.
How can I do this in Oracle?
SELECT * FROM Objects WHERE TRUNC(Columnname - TO_DATE('UserValue', 'DD.MM.YYYY')) =0; works great. But if I use < or > it doesn't do good because a truncated result of -0.35 or 0.67 is always 0! So it's not working in every cases.
Please give me tips or a good solution.
The same problem occurs in future if I try to use between, or?
Thanks,
Volker Received on Wed Oct 23 2002 - 08:42:18 CDT
![]() |
![]() |