| Author |
How to get records from a table in between dates
|
Harish Govind
Greenhorn
Joined: Nov 06, 2008
Posts: 8
|
|
I want to get records from a table between two dates. My requirement is a user can enter from date and two date. Based on dates i have to get records from the table which retrieves all records from the mentioned date. My table has both fromdate and todate columns. [ November 06, 2008: Message edited by: Bear Bibeault ]
|
Harish Govind
|
 |
Harish Govind
Greenhorn
Joined: Nov 06, 2008
Posts: 8
|
|
|
A user can be restricted to view few records for mentioned dates. If it is so then he should not get those records. For eg:- if a user is restricted between 16- 20 and he search for all records between 16-25 then he should get only records between 20-25 even if he mention dates between 16-25 as he restricted for those dates.
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
Hello Harish, so far what you tried ? where you stucked?you get any exception? if yes ,please post your exception
|
 |
Harish Govind
Greenhorn
Joined: Nov 06, 2008
Posts: 8
|
|
There is no exception in my code. I am getting improper results. The problem is with from date and todate. A user is restricted to view records of 15/10/08 to 18/10/08 dates and 24/10/08 to 28/10/08 dates. if he search records for 15/10/08 to 28/10/08 dates then he should be able to view only records between 18/10/08 to 24/10/08 as he is restricted for rest of the days. Logic can be written in java code using calendar class but i want it to hapen by simple sql statement.
|
 |
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1506
|
|
|
You will probaly need the calendar class to convert the user's entry so that the comparison on the back end can be done properly.
|
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
|
 |
Shawn Montague
Greenhorn
Joined: Aug 06, 2008
Posts: 25
|
|
select * from mytable where date_column_name between date1 and date2 is that what you mean?
|
 |
 |
|
|
subject: How to get records from a table in between dates
|
|
|