How to query date in sqlitedatabase

  • Replies:0
Coder05
  • Forum posts: 1

Mar 18, 2014, 12:52:22 AM via Website

Hi,
I have inserted date in sqlitedatabase and want to get results according to date for the last 7 days.

1String[] columns = new String[]{KEY_ROWID, KEY_NAME};
2 String result =" ";
3
4 long sevenDays = System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 7L;
5 Cursor c = ourDatabase.query(DATABASE_TABLE, null, KEY_DATE + " > "+ sevenDays, null, null, null, null);
6
7 int iRow = c.getColumnIndex(KEY_ROWID);
8 int iName = c.getColumnIndex(KEY_NAME);
9
10
11// How can I get all the names entered in the last 7 days. Thanks

Reply