gpt4 book ai didi

android - 无法按给定的特定月份检索数据

转载 作者:行者123 更新时间:2023-11-30 01:41:58 25 4
gpt4 key购买 nike

我想检索属于 12 的月份的数据。

 public Cursor readData()
{
Cursor c=database.rawQuery(" SELECT _id, Date,Weather,Status, TimeIn_Info, TimeOut_Info FROM " + MyDatabaseHelper.TABLE_INFO +
" WHERE strftime('%m',Date) = ? ",
new String[]{12+""}, null);
if (c != null) {
c.moveToFirst();
}
return c;
}

但是,没有显示任何数据。我确保它有一个 12 月的数据。

Table_Info 的 MyDatabaseHelper

     public static final String TABLE_INFO="Information";
public static final String Date="Date";
public static final String Status="Status";
public static final String TimeIn_Info="TimeIn_Info";
public static final String TimeOut_Info="TimeOut_Info";
public static final String Weather="Weather";
public static final String Name="Name";

public void onCreate(SQLiteDatabase db) {
db.execSQL("create table " + TABLE_INFO + " ( " + ID + " INTEGER PRIMARY KEY ,Name TEXT,Weather TEXT, Date DATETIME, Status Text, TimeIn_Info DATE TIME, TimeOut_Info DATETIME)");
}

我使用 date-time picker 选择日期,Date 保存格式为 19-12-2015 的日期。

There are nothing wrong with my database because data get displayed when I change the condition to name.

谁能帮我解决这个问题?

enter image description here

enter image description here

最佳答案

您可以尝试将插入日期时间更改为格式:2015-12-15 (%Y-%m-%d)

关于android - 无法按给定的特定月份检索数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34373159/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com