How to check that certain date in between of date?

前端 未结 2 1745
春和景丽
春和景丽 2020-12-12 06:46

I have a database in that there are two column start and end. start and end are in DD.MM.YYYY format.

I have a date which is also in DD.MM.YYYY format. How

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-12 07:16

    Use this below code. It will return number of days between two dates. Date are in format YYYY-MM-DD

    YourDatabse database=new YourDatabse (getApplicationContext(), 1);
     SQLiteDatabase sqlite=database.getReadableDatabase();
                Cursor fetch=sqlite.rawQuery("SELECT julianday('"+date2+"') - julianday('"+date1+"')", null);
                fetch.moveToFirst();
                sqlite.close();
                int noOfDays=fetch.getInt(0);
    

提交回复
热议问题