0

How do I query games that are after a "visible" date? The dateformat is set:

FMDatabase *db = self.database;
if([self.database open]){
    [db beginTransaction];

    NSDateFormatter *formatter = [NSDateFormatter new];
    [formatter setDateFormat:@"yyyy-dd-MM'T'HH:mm:ss'Z'"];
    [db setDateFormat:formatter];
    ...
}

The table is created the following way:

[db executeUpdate:@"CREATE TABLE IF NOT EXISTS game (gameId Varchar(36) NOT NULL PRIMARY KEY,name TEXT,visibleFrom TEXT)"];

The query is executed the following way:

FMResultSet *results = [db executeQuery:@"SELECT * FROM game WHERE game.visibleFrom >= ?,[NSDate date]];

This returns nothing. When I use select * from game then i get all the games. But I need the filtered result. Thanks in advance.

jww
  • 97,681
  • 90
  • 411
  • 885
jacob
  • 541
  • 1
  • 9
  • 19

1 Answers1

1

Take a look at the SQLite syntax for querying dates: sqlite select with condition on date You might need something like '@" ... where date > date(?)", formattedDate', where formattedDate is formatted like '1980-12-31'

Community
  • 1
  • 1
KrauseFx
  • 11,551
  • 7
  • 46
  • 53