HELLO i am trying to insert Current date in my database table i have a column dateVisited of type datetime
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy/MM/dd HH:mm:ss"]; //this is the sqlite's format
NSDate *stringTime = [NSDate date];
NSString *formattedDateStringTime = [formatter stringFromDate:stringTime];
sqlStr = [NSString stringWithFormat:@"Insert into AnwaltHistory (id,dateVisited) values (%d,'%@')",Id formattedDateStringTime];
NSLog(@"%@",sqlStr);
BOOL Res = [appDelegate InsUpdateDelData: sqlStr];
if (Res)
{
NSLog(@"The Following instrunction is excuted successfully !");
}
else
{
NSLog(@"The Following instrunction Failed to execute !");
}
the statement executes successfully but when i actually go and check the table it says invalid date... i dont know why as i have printed sqlstr i copy paste from the console and paste it in sqlite and run it manually it runs perfectly fine and has the actual date.... can any one guide me where i am mistaken :S....... please