I have a parameter, where user can choose for which period of time data should be stored.
I read it in days variable. Date and time, when record was added to the database is stored in KEY_DATE_ADDED, it is created like:
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // sql date format
Date date = new Date();
initialValues.put(KEY_DATE_ADDED, dateFormat.format(date));
Then I do the following:
mDb.delete(DATABASE_TABLE,
"date(now) > date(" + KEY_DATE_ADDED + ",+" + days + " days)",
null);
and it doesn't work. Actual query (where part) looks like:
WHERE date(now) > date(date_added,+10 days)
What is incorrect here? Looks like instead of date_added something else should be here.
I wanted to use SQL data formatting to avoid re-formatting dates several times.
Is there any GUI for Android database to test SQL queries on the actual data?
date('now') > date('date_added','+10 days')- it works now. So, the open question is only about GUI.adb pull /data/data/<namespace>/databases/<dbName>to pull the db from the emulator. I use the Firefox add-on "SQLite Manager" to view or edit the database.