lundi 14 mars 2016

how to query today, last week , last month sqlite data

In my app i have a database containing a column for date and date saved as long milliseconds. but the problem how to fetch today ,last week, last month entries. for today i tried this

String query = "select * from " + TABLE_NAME + " where " + COLUMN_DATE + " = date('now')"; Cursor cursor = db.rawQuery(query, null);

for week i tried

String query = "select * from " + TABLE_NAME + " where " + COLUMN_DATE + " = date('now','-7 day')"; Cursor cursor = db.rawQuery(query, null);

but it didn't work. any help appreciated.

Aucun commentaire:

Enregistrer un commentaire