How select data from SQLite table where date = week of year?
- by vovaxo
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)