android - Sqlite query to get unspecified month -


is there sqlite query unspecified month.

if have database entry 1 january 2014

and next entry

1 december 2014

can months during period. i.e. feb 2014 nov 2014

thanks in advance!!

this function returns me month , year of entries

public string[] getmonthsmood()         {         string result[]=null;             try             {                 int = 0;                 appdatabase = sqlitedatabase.opendatabase(strmypath, null, sqlitedatabase.open_readwrite);                 string selectquerry = "select distinct strftime('%y-%m',dateadded) mood_diary order dateadded";                 cursor cursor = appdatabase.rawquery(selectquerry, null);                 // int result=cursor.getcount();                 result = new string[cursor.getcount()];                 if (cursor.movetofirst())                     {                                                     {                                 // result.add(cursor.getstring(0));                                 result[i] = cursor.getstring(0);                                 i++;                             }                         while (cursor.movetonext());                     }                 return result;             }             catch (exception e)             {                 e.printstacktrace();             }             return result;         } 

in sqlite database put single entry string , date under comment , dateadded column.

you can try this:

with recursive months(m) (                             values(1)                             union                             select m+1 months limit 12                             )   select y || '-' || m yearmonth     (select case when m < 10 '0' || m else m end m months),          (select distinct strftime('%y', dateadded) y mood_diary)       yearmonth >      (select min(strftime('%y-%m', dateadded)) mood_diary) ,             yearmonth <      (select max(strftime('%y-%m', dateadded)) mood_diary) ,             yearmonth not in (select (strftime('%y-%m', dateadded)) mood_diary)   order yearmonth ; 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -