This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

returning all records from an sqlite3 database from a specific month and year

 
Greg Reeder
Ranch Hand
Posts: 99
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

I have an application that works with a SQLite3 database. This database, among other things, contains a list of records each of which contains an associated date. I want to be able to write a function for my java program that returns a list of these records that are associated with (for exampe) June 2011. I wrote one function in java that returns records between two specified specific dates, but there has to be a way to write an sql request that does it much easier. Does anyone know where I could find that out?

Thanks in advance,

Greg
 
Greg Reeder
Ranch Hand
Posts: 99
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think i just made the defining descovery. I can say "select * from tablename where dates > '2011-05' and dates < '2011-07'; This returns all records for may and june. I am assuming that that is because it registers '2011-05' to be the very first of the month of may rather than the last. Pretty logical, although that was not my first thought. I can now write a database access method requesting that this very query be used with the dates as a variable, but it would just have to be changed to '2011-06' and '2011-07'. I find it peculiar that I cannot just say dates = '2011-06', but even that is somewhat logical, just not easy. Any further ideas would be apreciated, but my acute problem is already solved.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34672
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg,
I'm not sure if your solution is cross browser compatibility. In answer to your question, I'm not sure if there is a better solution, I've always created a date with the first of the month.
 
Greg Reeder
Ranch Hand
Posts: 99
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Internet browsers play no role in the matter as it is a stand alone application. The dates are when a particular action takes place, and require a DAY_OF_MONTH field. But the solution I found works well.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic