如何在sqlite ios中比较月份和年份与日期时间
当我直接在sqlite manager中测试此查询时,它很好地显示了结果,但当我使用iphone模拟器测试时,它显示如下:如何在sqlite ios中比较月份和年份与日期时间,ios,datetime,sqlite,Ios,Datetime,Sqlite,当我直接在sqlite manager中测试此查询时,它很好地显示了结果,但当我使用iphone模拟器测试时,它显示如下: 如何解决这个问题 尝试转义SQL中的%字符,以便stringWithFormat知道不要尝试用值替换它们。比如: NSString* select = [NSString stringWithFormat:@"select * from orders where isPaid = 1 and strftime('%%Y-%%m',dateOrder) = '%@'",da
如何解决这个问题 尝试转义SQL中的
%
字符,以便stringWithFormat
知道不要尝试用值替换它们。比如:
NSString* select = [NSString stringWithFormat:@"select * from orders where isPaid = 1 and strftime('%%Y-%%m',dateOrder) = '%@'",dateString];
将代码查询替换为以下内容
NSString* select = [NSString stringWithFormat:@"select * from orders where isPaid = 1 and strftime('%%Y-%%m',dateOrder) = '%@'",dateString];
列“dateOrder”的类型是datetime!谢谢,和上面的答案一样!