数据不能由给定的特定月份中检索 [英] Data cannot be retrieved by given a specific month

查看:158
本文介绍了数据不能由给定的特定月份中检索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检索数据的哪个月是属于12。

I wanted to retrieve data which month is belong to 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个月数据。

However, no data get displayed. I have make sure it has a data with a month 12.

MyDatabaseHelper为Table_Info

     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)");
      }

我选择使用日期日期时间选择器和日期保存与格式日期 19-12-2015

I select the date by using date-time picker and the Date holds the date with the format 19-12-2015.

有什么错我的数据库,因为数据显示得到
  当我改变的条件名称。

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

有人可以帮我找出这个问题?

Can someone helps me to figure out the problem ?

在这里输入的形象描述

在这里输入的形象描述

推荐答案

您可以尝试插入日期时间变更为格式为:2015年12月15日(%Y-%M-%D)

you can try to change insert datetime to format: 2015-12-15 (%Y-%m-%d)

这篇关于数据不能由给定的特定月份中检索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆