• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to get records from a table in between dates

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
select * from mytable where date_column_name between date1 and date2

is that what you mean?
 
Do the next thing next. That’s a pretty good rule. Read the tiny ad, that’s a pretty good rule, too.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic