开发者

Android sqlite date comparison?

开发者 https://www.devze.com 2023-01-22 07:57 出处:网络
How can I compare dates using where statement in sqlite? I don\'t know how to write date in timestamp format in DB.

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, 
        开发者_JAVA百科       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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号