Reputation: 5540
I have a problem while retrieving DateTime from sqlite3. For Example to retrieve an int value we use
sqlite3_column_int(selectstmt, 1);
In the same way what function I have to use to retrieve the DateTime and how to convert it to NSDate.
Upvotes: 1
Views: 1778
Reputation: 2235
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
char* value = (char *)sqlite3_column_text(selectStatement, 2);
if(value != nil){
NSString *dateTest = [NSString stringWithUTF8String:value];
[dateFormatter setDateFormat:@"yyyy-MM-dd"]; //sample date format
NSString *formattedDateString = [dateFormatter stringFromDate:matchDate];
}
Upvotes: 1
Reputation: 51374
You have to retrieve it as text sqlite3_column_text
, and convert it to date, using proper date format, if you want.
Upvotes: 2