android - How to pass yyyy-mm String to yyyy-mm-dd datetime string to filter records from sqlite? -


here have datetime string in yyyy-mm-dd format like

  1. 2016-08-26
  2. 2016-09-21
  3. 2015-07-23
  4. 2016-04-25

what need if pass 2016-08 in parameter need record of 2016-08-26 need how can achieve far have tried

  public list<customermodel>date(string year){         string countquery ="select * "+customermodel.customertable + " " +customermodel.customer_createdat +  " strftime('%y-%m',"+customermodel.customer_createdat+")  = "+year  +"";         cursor cursor = db.rawquery(countquery, null);         list<customermodel>list=new arraylist<>();         if(cursor!=null && cursor.getcount()>0){             if(cursor.movetofirst()){                 do{                     customermodel accountmodel=new customermodel();                     accountmodel.setcreatedbyname(cursor.getstring(cursor.getcolumnindex(customermodel.customer_createdby)));                     //   accountmodel.setcreatedat(cursor.getstring(1));                     list.add(accountmodel);                 }while (cursor.movetonext());             }         }           if(cursor!=null){             cursor.setnotificationuri(mcontext.getcontentresolver(),db_timetracker );         }         return list;     } 

am getting sqlite exception how achieve possible in advance.

try query

select * table_name created_date '2016-08%' 

this give multiple records if have more 1 date particular year , month. replace date sting using string functions date field.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -