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 is converted to timeInMilliseconds(correct me if im wrong) default to active android Date object, How do I get today query?
If you are storing your date as INTEGER, try this:
Your query should be like this :
SQLite allows selecting current date, time and timestamp like this :
The output of above query will be like this :
If you are storing date as integer or unix epoch then do the following : 1. Get the current time in milliseconds in JAVA. Lets say it is current_time_in_mill
Then use the following query
Example try this :
select date(1092941466, 'unixepoch')