如何在SQLite今天查询 [英] how to query today in sqlite

查看:173
本文介绍了如何在SQLite今天查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用sqlite的android系统中有一个本地数据库,我使用了活动的android系统,而我的表pojo是这样的:

I have a local database in android using sqlite , i used active android and my table pojo is like this:

@Column(index = true, unique = true , onUniqueConflict = Column.ConflictAction.REPLACE)
public long taskId;
@Column( index = true)
public String taskIdno;
@Column()
public String taskDescription;
@Column()
public String taskTypeId;
@Column()
public String customerName;
@Column()
public String customerContact;
@Column()
public String address;
@Column(index = true)
public int status;
@Column()
public Date startSchedule;
@Column()
public int first_visit;
@Column()
public String coordinates;
@Column()
public int radius;
@Column()
public long location_type_id;
@Column()
public long duration;
@Column()
public long taskType_id;

我的问题是我今天的查询不起作用,或者这里缺少某些信息。

My problem is that my query for today doesnt work, Or there is something im missing here.

  public static List<AATask> allTaskOrderedByDate(String asc_desc){
        From from = new Select().from(AATask.class).where("strftime('%Y-%m-%d', startSchedule ) = strftime('%Y-%m-%d' , DATE('now'))").orderBy("startSchedule ".concat(asc_desc));
        Log.w(TAG , from.toSql());
        return from.execute();
    }

startSchedule转换为timeInMilliseconds(如果输入不正确,请更正我)默认为活动的android日期对象,如何获取今天的查询?

startSchedule is converted to timeInMilliseconds(correct me if im wrong) default to active android Date object, How do I get today query?

推荐答案

如果将日期存储为INTEGER,请尝试以下操作:

If you are storing your date as INTEGER, try this:

select * from my_table where date(dateColumn) = date('now');

这篇关于如何在SQLite今天查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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