Two SQLite tool recommendations
In regards to my post yesterday on AIR and SQLite I thought I'd share two tools that can help developers.
I've been using a cool AIR based SQLite tool from Christophe Coenraets. You can find it here. It works rather nicely and I like that it has a 'history' feature since I always have trouble finding the exact location AIR stores my DB file. (I typically trace the nativepath of my File object when I forget.)
Then a commenter named Gareth pointed out that you can find a Firefox plugin as well. (About the only thing you can't do in a Firefox plugin is peace in the Middle East.) I installed the SQLite Manager today and it runs pretty well.
I'm not sure which tool I'll give preference too, and I'm sure there are others as well.
And lastly, if any AIR/SQLite experts out there want to help me with my date problem, let me know.
Comments
But I'm trying to do a simple date comparison. Ie, get * from hours where date > today and nothing I try seems to work.
Look at this, it says Sqlite is Typeless. Everything is considered as a string. It might be best to save dates as numerics and then do a comparison.
var currentTime:Number = now.getTime();
that should give you the number of seconds since January 1, 1970. Pretty good to use that for date comparisons.
To get it to work you add SQLite JDBC driver to your java path, and then datasource URL is something like "jdbc:sqlite:/path/to/airapp.db" and driver is "org.sqlite.JDBC".
http://code.google.com/p/asqlib/
Instead of writing sql statements all by yourself, those classes can ganerate sql statements for you. It's still work in progress, so expect changes - more classes for larger sql support.
Have a nice day.
where datetime(t.time, 'unixepoch', 'localtime') > datetime('now', '-25 days', 'localtime')
the site that documents the datetime function is here:
http://www.sqlite.org/cvstrac/wiki?p=DateAndTimeFu...
hope this helps
Error:
near "unixecpoch": syntax error
My precise sql:
select *
from hours
where datetime(hours.date, 'unixepoch', 'localtime') > datetime('now', '-25 days', 'localtime')
http://www.sqlmaestro.com/products/sqlite/
Christophe's tool is also useful (as u mentioned)
select * from hours
where date > date('now')
if it doesn't work, i would ask for your create table statement and/or what your data looks like when you select it. i feel certain this is in the format of your data.
also, to one of the other posts, aqua data is a great tool. it natively connects to all the major db's, and will connect to anything else with an odbc or jdbc driver. it is a very sweet tool.
http://www.coldfusionjedi.com/index.cfm/2008/1/9/W...
Enter a project, client, then a few hours, and you will have sample data.
Looking at your date values, it looks like they're getting entered strangely into the dB. It looks like it's adding milliseconds to the date. It shows up in SQLite Manager as 1199941200000, but when converting back to a string date, this will not convert properly. However, if you remove the last 3 zeros, it comes back correctly at 2008-10-1.
SELECT * from hours
where date('now') <= date(date, 'unixepoch')
Try this
SELECT *
FROM hours
WHERE date('now', 'localtime') <= date(date, 'unixepoch', 'localtime')
This will add 5 hours to the date time (if you are EST) to account for the time difference from GMT.
1/11/08
Should I have store 2008-11-1 instead?
select * from hours
where datetime(hours.date, 'unixepoch', 'localtime') > date('now')
if this doesn't work, then please post/send the updated code.
select * from hours
where datetime(hours.date, 'unixepoch') >= date('now')
I'm not sure why it's not working. If it returns the date correctly, I'm guessing that it should be working. What do you get if you type in
select date('now') from hours
(just to see what is returned when you select "now")?
Another thing to try is messing around with the unixepoch dates and see if you can get it to return something. I went to this page http://www.esqsoft.com/javascript_examples/date-to...
and grabbed some converted dates and put them into the query to test against and see what was returned.

