Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
352 views
in Technique[技术] by (71.8m points)

android - SQLite select rows if timestamp matches today's date

I Would like to select all entries from an SQLite table if the entries timestamp matches todays date.

I am querying an SQLite database as follows:

// Tasks table name
private static final String TABLE_TASKS = "tasks";

// Tasks Table Columns names
private static final String KEY_ID = "id";
private static final String KEY_TIMESTAMP = "timestampGMT";
private static final String KEY_DESCRIPTION = "description";


String selectQuery = "SELECT  * FROM " + TABLE_TASKS + " WHERE "+ KEY_TIMESTAMP+">=date('now', '-1 day')";

This behavior is the closest I have come but I do not wish to select all entries within the last 24hrs. I only want to select if todays date matches the timestamp.

How can I select only the rows in the table who's timestamp matches todays date.

date format is: 2014-07-05 12:59:35 in the database.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

does this work?

date('now', 'start of day')

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...