Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Problem with dates in select

Problem with dates in select

From: Volker Schmid <Info_NoSpam_at_Inspirant.de>
Date: Wed, 23 Oct 2002 15:42:18 +0200
Message-ID: <ap68st$tcf$1@news.online.de>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US