• 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

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

 
Ranch Hand
Posts: 99
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic