Display Last Week Records & Delete Previous Records in iPhone Application using Sqlite3 database -
i want display lastly week records & delete previous records in iphone application.
so i'm getting 1 week later date-time using,
//now nowdate = [entrydateformat stringfromdate:[nsdate date]]; //1 week previous weekdate = [entrydateformat stringfromdate:[[nsdate date] datebyaddingtimeinterval: -604800.0]];
then, executing sql query like
nsstring *selectsql = [nsstring stringwithformat:@"select * tbltest time between \"%@\" , \"%@\"", weekdate, nowdate];
so getting value of query ::
select * tbltest time between "04-02-2013 17:20:36" , "11-02-2013 17:20:36";
same delete previous records
delete tbltest time < "04-02-2013 17:20:36";
so, it'll work 1st, 2nd & 3rd of current date. it'll not executes previous month's dates '30-01-2013' & '31-01-2013'.
i've seek this:
delete tbltest time < date('now','-7 days');
but no results.:(
what functions sqlite side, can perform operation based on functions , exact values lastly week records.?
please help me situation.
thanks in advance.
in sqlite, timestamps should stored year field first, i.e., in format yyyy-mm-dd hh:mm:ss
.
iphone database datetime sqlite3
No comments:
Post a Comment