There is a table in the database that contains a set of some records, one of the fields in the row of this table is of type text and contains a date in this format:
SimpleDateFormat dataFromat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); cvHeader.put(dbConnector.ORDER_DATE,dataFromat.format(currentDate)); Now I want to select data from this table. The logic is as follows: there is a field in the activation with the choice of the date when the user selects it, then the variables are entered for the year, month and day, respectively, here is an example:
private static Date changeCalendarDay(int daysCount, int field) { GregorianCalendar calendar = new GregorianCalendar(); calendar.set(year,month,day); calendar.add(field,daysCount); year = calendar.get(GregorianCalendar.YEAR); month = calendar.get(GregorianCalendar.MONTH); day = calendar.get(GregorianCalendar.DATE); return calendar.getTime(); } This method jerks when the user increases or decreases the current date by 1. So, the user changed the date, recorded values in the variables, then the method that fetches data from the database is called and displays the result in a log. But I can not select records from the database, I do this:
dbConnector dbConnector = new dbConnector(getContext(),BasicSettings.Main_DB_Name,BasicSettings.Current_DB_Version); db = dbConnector.getWritableDatabase(); String targetDate = "'"+year + "-"+(month)+"-"+day+"'"; Cursor cursor = db.query(BasicSettings.OrderHeaders_DB_Table, dbConnector.ALL_ORDER_HEADERS_COLS_LIST, dbConnector.ORDER_DATE + "=?", new String[]{targetDate}, null, null, null); if (cursor != null) { if(cursor.moveToFirst()) { do { Log.d("ORDERSINFO",cursor.getString(cursor.getColumnIndex(dbConnector.ORDER_CODE))); } while (cursor.moveToNext()); } } But the records do not find ... Is it possible to somehow make a sample, so as not to alter the way the date is stored in the database? How to do right?