SQLite按datesorting
我的SQLite数据库中的每条logging都包含一个字段,其中包含一个Date ,格式为'yyyy-MM-dd HH:mm:ss' 。 
是否可以查询数据库以获取包含最近date的logging?
你可以这样做
 SELECT * FROM Table ORDER BY date(dateColumn) DESC Limit 1 
对我来说,我有这样的查询来解决我的问题
 select * from Table order by datetime(datetimeColumn) DESC LIMIT 1 
因为我把它存储为date时间date列
您需要将其转换为unix时间戳,然后比较它们:
 SELECT * FROM data ORDER BY strftime('%s', date_column) DESC 
但是如果有很多行,这可能会很慢。 更好的方法是默认存储unix时间戳,并为该列创build一个索引。
您可以将列“sent_date_time”转换为yyyy-MM-dd格式,然后按datesorting
 1 ) substr(sent_date_time,7,4)||"-"||substr(sent_date_time,1,2)||"-"||substr(sent_date_time,4,2) as date 2) order by date desc 
 当你确定文本字段的格式是yyyy-MM-dd HH:mm:ss (例如: 2017-01-02 16:02:55 ),那么它对我来说简直就是: 
 SELECT * FROM Table ORDER BY dateColumn DESC Limit 1 
没有任何额外的datefunction!