Android的SQLite的日期比较? [英] Android sqlite date comparison?
本文介绍了Android的SQLite的日期比较?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何可以比较使用WHERE语句SQLite中的日期?
我不知道怎么写的时间戳格式日期DB。
我想只有时间戳记格式(数据库整数或字符串)我能比?!
有人可以帮助我与code为DB写日期(使用ContentValues)
我想用这个code进行比较:
光标mCursor =
db.query(真实的,
tableName值,
空值,
KEY_DATETIME +> ='+寄件者+和+
KEY_DATETIME +< ='+ TODATE +',
空值,
空值,
空值,
空值,
空值);
解决方案
您可以考虑存储的日期作为的SQLite数据库有几个优点很长。请参见我的其他问题和更多信息接受的答案。
How can I compare dates using where statement in sqlite? I don't know how to write date in timestamp format in DB. I guess only timestamp format (integer or string in database) I can compare?!
Can someone help me with code for writing date in db (using ContentValues )
I want to use this code for comparison:
Cursor mCursor =
db.query(true,
tableName,
null,
KEY_DATETIME + " >= '"+ fromDate +"' and " +
KEY_DATETIME + " <= '"+ toDate +"'" ,
null,
null,
null,
null,
null);
解决方案
You might consider storing the date as a long in the SQLite DB which has several advantages. See my other question and the accepted answer for more information.
这篇关于Android的SQLite的日期比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文