你好我正在尝试在我的数据库表中插入当前日期我有一个日期时间类型的列 dateVisited
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 !");
}
该语句成功执行但是当我实际去检查表时它说无效日期......我不知道为什么我打印了sqlstr我从控制台复制粘贴并将其粘贴到sqlite并手动运行它运行得很好并且有实际日期....任何人都可以指导我在哪里我弄错了:S.......请