Yatin
Yatin

Reputation: 3120

Require Rows which lies between two dates

I got table having dates columns as ValidFrom and ValidTo It has data which is valid for that range of days . If I have current date as my date to send which checks for dates between ValidFrom and ValidTo . How can I get rows of data which satisfies the condition for two columns of dates instead of having to look into each row.

Upvotes: 0

Views: 40

Answers (1)

Andrey Danilov
Andrey Danilov

Reputation: 6602

Just make rawQuery

Cursor cursor = db.rawQuery("SELECT * FROM table WHERE ValidFrom < %yourDate% AND ValidTO < %yourDate%;", null);

cursor.moveToFirst();
while ( !cursor.isAfterLast()) {
        //get here values you need from raw
            cursor.moveToNext();
}

Upvotes: 2

Related Questions