How to select data between two date range in android SQLite

18,682

You can do something like this:

 mDb.query(MY_TABLE, null, DATE_COL + " BETWEEN ? AND ?", new String[] {
                minDate + " 00:00:00", maxDate + " 23:59:59" }, null, null, null, null);

minDate and maxDate, which are date strings, make up your range. This query will get all rows from MY_TABLE which fall between this range.

Share:
18,682
Adil Bhatty
Author by

Adil Bhatty

droid guy

Updated on June 11, 2022

Comments

  • Adil Bhatty
    Adil Bhatty almost 2 years

    I have table which contains data along with created on date. I want to select data from table according to two given date ranges, or of one particular month.

    I am not sure how to do that, as created on column is of type text and is stored as dd-MM-yyyy HH:mm:ss

    I am using rawQuery() to fetch data.