Posted By Our Mentors
Amreen Khan
Android Developer
animesh bansal
iphone App Developer
Devendra chouksey
Android Developer
Dilip Saket
IOS apps developer
Hemraj Jhariya
iOS Developer
Jaihind singh Rajput
Smart Phone App Dev
Mujahid khan
Android developer
Narendra Yadav
android developer
Narinder Gupta
Mobile App Architect
Pradeep singh Thakur
Mobile App Architect
Sanjay Sharma
Andriod Developer
Shakti Rajpal
IT Architect
Soniya Vishwakarma
iPhone App Developer
Sunil Raghuwanshi
iPhone App Developer
Supriya Kapse
Senior developer
Storing String Date In Sqlite Database Iphone/iPad
Performing Record retrievals on parameter basis from Sqlite database is hard stuff. Most of us dig up for the such kind of information and to further use date functionality that seem to be little hard but can be achieved by using few procedures.
Posted By: Dilip Saket Date: 14 Jan 2014 View: 1664
      Rate This !!


Retrieving the records from the sqlite database on the basis of date parameter is little hard. Because versatile requisition might require getting information in the underneath conduct: 

  • Fetch number of records request by date climbing and dropping
  • Fetch records between two dates
  • Fetch record after a date 
  • Fetch record before a date

In sqlite database we store date as string and all the date capacities neglects to recover information consistent with the date. Saving date string in an organized manner can take care of the date issue.

To tackle this issue dependably store date in the arrangement 'yyyy-MM-dd Hh:mm:ss' OR 'yyyy-MM-dd Hh:mm:ss a'. Here the single digit for date, month, hour, moment, and seconds might as well accompany the 0.

For Example: 

Assuming that our date is 'Jun 5th, 2013 6:30:11' we can change this date to a arrangement of 'yyyy-MM-dd Hh:mm:ss' OR 'yyyy-MM-dd Hh:mm:ss a'.

In the wake of changing the date to this organization, the date will be: 

'2013-06-05 06:30:11' OR '2013-06-05 06:30:11 AM' 

In this date group we can sort the sqlite information by utilizing the sqlite query. We can bring the records after or before a date. We can bring the information between two dates.

Select * from tablename request by date sac

Select * from tablename request by date desc

Select * from tablename where date > '2014-01-01 02:30:18' 

Select * from tablename where date between '2013-09-01 02:30:18' and '2014-01-01 02:30:18' 

Besides, here you need to change the date arrangement to show in your views. Doesn’t stress over this simply make a method which will furnish a proportional payback date organized string.

Use this date format in your application globally.

#define databasedateformat @"yyyy-MM-dd Hh:mm:ss".

Date configuration changing strategy will take three parameters in it.

1. Current Date String (strdate)

2. Current Date Format (strcurrentformat OR databasedateformat)

3. Specified Date Format (strspecifieddateformat)

For Example:

- (Nsstring *)getformatteddate:(nsstring *)strdate currentdateformat:(nsstring *)strcurrentformat withdate:(nsstring *)strspecifieddateformat

{

 Nsstring *resulteddatestring;

 Nsdateformatter *dateformatter  =  [[nsdateformatter alloc]init];

 [dateformatter setdateformat:strcurrentformat];

 Nsdate *currentdate =  [dateformatter datefromstring:strdate];

 if(currentdate !=nil)

 {

 [dateformatter setdateformat:strspecifieddateformat];

 resulteddatestring = [dateformatter stringfromdate:currentdate];

 }

 else

 {

 resulteddatestring = strdate;

 }

 return resulteddatestring;

}

Above approach will undertake the issue acknowledged with date arrangement.

I cheated on my boyfriend reasons why wives cheat on their husbands open

Posted Queries