【发布时间】:2014-01-03 12:55:18
【问题描述】:
我正在尝试解决问题 我将数据保存在 sqlite 中。 日期格式为
NSDateFormatter *df= [[NSDateFormatter alloc]init];
df.dateStyle = NSDateFormatterMediumStyle;
df.dateFormate = @"dd-MM-yyyy";
DateTextField.text = [NSString stringWithFormat:@"%@",[df stringFromDate:MyPicker.date]];
Sqlite 表中保存的值。
我在表 currentdate,pastdate,futuredate 中有三个按钮。
当我按下当前日期按钮时,当前日期值显示在表格中,
当我按下过去日期按钮时,过去日期值显示在表格中,
当我按下futuredate按钮时,futuredate值显示在表格中。
在过去的日期是按 sqlite 查询排序数据
NSString *Querysql = [NSString stringWithFormate:@"SELECT *FROM Table_Name where Date > '16-12-2013' order by date DESC"];
如何在当前日期显示?
获取当前日期、sqlite 表中的值的查询是什么?
【问题讨论】:
-
使用“dd-MM-yyyy”会使您的代码过于复杂,并阻止您使用许多优化,例如
INDEXes。使用“yyyy-MM-dd”将日期存储在数据库中,并根据需要在应用程序中显示格式。检查SQLite date/time。
标签: ios sql objective-c sqlite