Here you get only one date which is near to the supplied date. You can remove MAX to get all dates...
Code:
SQL> SELECT * FROM testdate ORDER BY datum;
ID DATUM
---------- ----------
1 21.11.1996
1 29.07.1999
1 27.11.1999
1 25.06.2000
1 21.01.2001
1 21.04.2001
1 30.07.2001
1 04.05.2002
1 15.05.2002
1 22.07.2002
1 23.08.2002
1 03.10.2002
1 07.10.2002
1 30.10.2002
1 12.11.2002
1 21.11.2002
1 22.11.2002
1 30.11.2002
1 13.12.2002
1 14.12.2002
1 15.12.2002
21 rows selected.
SQL> SELECT MAX(datum) FROM testdate WHERE datum < (SELECT MAX(datum) FROM testdate
2 WHERE datum = TO_DATE('&date','DD.MM.YYYY'));
Enter value for date: 22.07.2002
old 2: where datum = to_date('&date','DD.MM.YYYY'))
new 2: where datum = to_date('22.07.2002','DD.MM.YYYY'))
MAX(DATUM)
----------
15.05.2002
SQL> /
Enter value for date: 27.11.1999
old 2: where datum = to_date('&date','DD.MM.YYYY'))
new 2: where datum = to_date('27.11.1999','DD.MM.YYYY'))
MAX(DATUM)
----------
29.07.1999
SQL> /
Enter value for date: 23.08.2002
old 2: where datum = to_date('&date','DD.MM.YYYY'))
new 2: where datum = to_date('23.08.2002','DD.MM.YYYY'))
MAX(DATUM)
----------
22.07.2002
SQL>
Sameer
Bookmarks