i need data in between current date last month (means last 30 days) sqlite. here code list of data nothing this.
public list<birthday> getweekbirthdays() { list<birthday> birthdays = new arraylist<birthday>(); sqlitedatabase db = this.getreadabledatabase(); calendar theend = calendar.getinstance(); calendar thestart = (calendar) theend.clone(); thestart.add(calendar.day_of_month, -30); simpledateformat dateformat = new simpledateformat("yyyy-mm-dd"); string start = dateformat.format(thestart.gettime()); string end = dateformat.format(theend.gettime()); string datequery = "select * " + table_birthday + " " + key_event_date + " between " + start + " , " + end; log.e(log, datequery); cursor c = db.rawquery(datequery, null); log.e(log, "no of birthday : " + c.getcount()); if (c.movetofirst()) { { birthday birthday = new birthday(); birthday.setname(c.getstring(c.getcolumnindex(key_user_name))); birthday.seteventtype(c.getstring(c .getcolumnindex(key_event_type))); birthday.seteventdate(c.getstring(c .getcolumnindex(key_event_date))); birthday.setid(c.getint(c.getcolumnindex(key_id))); birthdays.add(birthday); } while (c.movetonext()); } return birthdays; }
i not error please me , tell me how these data.
thanks
one way is
string query="select * "+table_birthday +" "+ key_event_date +" >= date('now','localtime', '-30 day')"; cursor c = mydatabase.rawquery(query,null);
it fetch last 30 days
records today. key_event_date
must have values in yyyy-mm-dd
works.
Comments
Post a Comment