Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get records from a table in between dates

 
Harish Govind
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Harish,

so far what you tried ? where you stucked?you get any exception? if yes ,please post your exception
 
Harish Govind
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Shawn Montague
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
select * from mytable where date_column_name between date1 and date2

is that what you mean?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic