Query [message #373355] |
Thu, 12 April 2001 06:52 |
Kumar
Messages: 115 Registered: December 1998
|
Senior Member |
|
|
Hi
How to retrieve the record from table using TWO dates.
Eg. Suppose i am giving 11-04-2001 to 13-04 -2001.
In the below query i am getting only records of 12 and 13th.I am unable to get record of 11th.Please help us to find the correct solution.
Select unique id from emp where
doj>=to_date('"+from+"','dd-mm-yyyy') and
doj<=to_date('"+to+"','dd-mm-yyyy') ;
thanks in advance
regards
kumar
|
|
|
Re: Query [message #373358 is a reply to message #373355] |
Thu, 12 April 2001 08:53 |
Madhav Kasojjala
Messages: 42 Registered: November 2000
|
Member |
|
|
Hi,
use trunc on from & to dates....
above condition is comparing timestamps too...
when u are using date comparision better using
trunc...
select ...
from....
where trunc(col_date) between
trunc(fr_date) and trunc(to_date)...
HTH
Madhav
|
|
|
Re: Query [message #373422 is a reply to message #373358] |
Mon, 16 April 2001 11:22 |
Hari
Messages: 59 Registered: August 2000
|
Member |
|
|
trunc(col_date) is not good practice of writing query
it shud be
select * from tablw
where col_date between trunc(fr_date) and trunc(to_date) + 0.99999
So that the indexes are used properly.
|
|
|
Re: Query [message #373423 is a reply to message #373358] |
Mon, 16 April 2001 11:22 |
Hari
Messages: 59 Registered: August 2000
|
Member |
|
|
trunc(col_date) is not good practice of writing query
it shud be
select * from table
where col_date between trunc(fr_date) and trunc(to_date) + 0.99999
So that the indexes are used properly.
|
|
|
Re: Query [message #373616 is a reply to message #373355] |
Thu, 26 April 2001 15:36 |
unknown
Messages: 12 Registered: April 2001
|
Junior Member |
|
|
select name,sal,mdate from proj
where MDATE >= to_char(to_date('01-APR-01', 'DD-MON-YY'), 'DD-Mon-yyyy') AND
MDATE <= to_char(to_date('04-APR-01', 'DD-MON-YY'), 'DD-Mon-yyyy') ORDER BY MDATE
TRY THIS ONE
|
|
|