How select data from SQLite table where date = week of year?
Posted
by
vovaxo
on Stack Overflow
See other posts from Stack Overflow
or by vovaxo
Published on 2012-09-15T09:36:15Z
Indexed on
2012/09/15
9:37 UTC
Read the original article
Hit count: 182
I have table expense:
"create table " + Expense.TABLE_NAME + "("
+ Expense.ID
+ " integer primary key autoincrement not null, "
+ Expense.CATEGORY_ID + " integer, " + Expense.ITEM
+ " text, " + Expense.PRICE + " real, " + Expense.DATE
+ " date, " + Expense.TIME + " time);";
And I want to select Expense.PRICE
where Expense.DATE
= current day/week/month.
I tried to do this
cursor = mDB.rawQuery("select " + Expense.PRICE + " where "
+ " (strftime('%W', " + Expense.DATE + "))" + "=" + week,
null);
where week is week = calendar.get(Calendar.WEEK_OF_YEAR);
but it gives an error in cursor:
09-15 09:32:02.647: E/AndroidRuntime(18939): Caused by: java.lang.NullPointerException
09-15 09:32:02.647: E/AndroidRuntime(18939): at com.pllug.summercamp.expensemanager.DataAdapter.getPrice(DataAdapter.java:242)
© Stack Overflow or respective owner