Joanne
Joanne

Reputation: 35

Select data out sqlDB by currentDate

How can I select from the database only the tasks from the current day. I have already an variable with the name currentDate. Therein I can store the current day. I've already tried by selectArgs doing this > "SELECT WHERE" + TaskContract.Columns.DATE + " == " currentDate

Cursor cursor = sqlDB.query(TaskContract.TABLE,
            new String[]{TaskContract.Columns._ID,TaskContract.Columns.TIME, TaskContract.Columns.TASK},
            null, null, null, null, TaskContract.Columns.TIME + " ASC");

Upvotes: 0

Views: 25

Answers (1)

George Mulligan
George Mulligan

Reputation: 11923

Try the following:

Cursor cursor = sqlDB.query(TaskContract.TABLE,
            new String[]{TaskContract.Columns._ID,TaskContract.Columns.TIME, TaskContract.Columns.TASK},
            TaskContract.Columns.DATE + " = ?",
            new String[] {currentDate},
            null,
            null,
            TaskContract.Columns.TIME + " ASC");

Upvotes: 1

Related Questions