My database has the following table:
database.execSQL("create table " + TABLE_LOGS + " ("
+ COLUMN_ID + " integer primary key autoincrement,"
+ COLUMN_ID_DAY_EXERCISE + " integer not null,"
+ COLUMN_REPS + " integer not null,"
+ COLUMN_WEIGHT + " real not null,"
+ COLUMN_1RM + " real not null,"
+ COLUMN_DATE + " integer not null"
+ ")");
I save the unix timestamp in the COLUMN_DATE field (integer).
Now I have the following function that captures all records:
public Cursor fetchCurrentLogs(long dayExerciseDataID) {
Cursor cursor = database.rawQuery("select " + MySQLiteHelper.COLUMN_ID + "," + MySQLiteHelper.COLUMN_REPS + ", " + MySQLiteHelper.COLUMN_WEIGHT + " " +
"from " + MySQLiteHelper.TABLE_LOGS + " " +
"where " + MySQLiteHelper.COLUMN_ID_DAY_EXERCISE + " = '" + dayExerciseDataID + "'", null);
if (cursor != null) { cursor.moveToFirst(); }
return cursor;
}
Now, what I want to do, I want this feature to only capture recordings today.
Then I want to make another function exactly the same, but instead of getting records for today, I want her to get records for the previous day. I used to mean the very last day, which has notes that are not today. So it can be yesterday, or 3 days ago, or a month ago.
I know that in MySQL you can do something like this on the current day:
where date_format(from_unixtime(COLUMN_DATE), '%Y-%m-%d')= date_format(now(), '%Y-%m-%d')
What is equivalent to this for SQLite?
, - where , ?
.