Note that there are some explanatory texts on larger screens.

plurals
  1. POHow would I compare NSDate from my database of type TIMESTAMP?
    primarykey
    data
    text
    <p>In my sqlite database I have a column named datekey of type TIMESTAMP.</p> <p>How would i match two timestamps ?</p> <p>I am using this:</p> <pre><code>NSString *Sql =@"SELECT ZTIMESLOT,ZAGENDA1,ZAGENDA2 FROM tbl_agenda where tbl_agenda.ZDATEKEY=%d"; NSString *sqlFormated = [NSString stringWithFormat:Sql,date]; </code></pre> <p>where date is of type NSDate.</p> <p>But as i can see in my database timestamp value for 26 feb is 1298678400 which is correct but when i am trying to match with above source code then date value become 78756944 which is complete wrong for comparison.</p> <p>Please help</p> <p>My complete code</p> <pre><code>-(NSMutableArray*)getAgendaDetail:(NSDate*)date </code></pre> <p>{</p> <pre><code>NSMutableArray *DateArr=[[NSMutableArray alloc]init]; sqlite3 *database; @try { DBSettings *dbSettings = [[DBSettings alloc]init]; [dbSettings checkAndCreateDatabase]; DatabaseName=dbSettings.DBName; DatabasePath=dbSettings.DBPath; [dbSettings release]; if(sqlite3_open([DatabasePath UTF8String], &amp;database) == SQLITE_OK) { // Setup the SQL Statement and compile it for faster access const char *sqlStatement; //NSString *Sql = @"SELECT * FROM song_info where id_song=%d" ; NSString *Sql =@"SELECT ZTIMESLOT,ZAGENDA1,ZAGENDA2 FROM tbl_agenda where tbl_agenda.ZDATEKEY=%lu"; NSString *sqlFormated = [NSString stringWithFormat:Sql,date]; sqlStatement=[sqlFormated UTF8String]; sqlite3_stmt *compiledStatement; if(sqlite3_prepare_v2(database, sqlStatement, -1, &amp;compiledStatement, NULL) == SQLITE_OK) { while(sqlite3_step(compiledStatement) == SQLITE_ROW) { --------------------------- </code></pre> <p>getting complete wrong value for sqlFormatted as compared to database value</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload