Reputation: 2284
how can i change the followin queries to convert from varchar to date & time type. -in my tabele columns are 'time'(DATETIME), 'Comments'(VARCHAR)
(NSMutableArray *)selectAllFromDB {
time=[NSString stringWithUTF8String:(char *)sqlite3_column_text(selectAllStmt, 0)];
} __
-in insert method
-(BOOL)insertIntoDB:(NSMutableDictionary *)dict
{
time=[dict objectForKey:@"time"];
if(sqlite3_bind_text(insertStmt, 1, [time UTF8String], -1, SQLITE_TRANSIENT) != SQLITE_OK)
{
return NO;
}
}
how to modify these queries for date data type
Upvotes: 0
Views: 648
Reputation: 8053
Try this:-
-(BOOL)insertIntoDB:(NSMutableDictionary *)dict
{
time=[dict objectForKey:@"time"];
if((sqlite3_bind_double(insert_statement, 1, [time timeIntervalSince1970])) != SQLITE_OK)
{
return NO;
}
}
Upvotes: 1