Android将日期插入到datetime SQLite中

时间:2017-04-02 22:37:03

标签: android sqlite date datetime

我正在使用sqlite-android,它包含一个带字段的表" datetime",

我试图在该表中插入一个值:

select a.*
from alerttimes a
where (time_on <= time_off and cast(getdate() as time) >= time_on and cast(getdate() as time) < time_off) or
      (time_on > time_off and cast(getdate() as time) <= time_on and cast(getdate() as time) >= time_off);

s.getDate返回日期元素。但似乎我不能使用我向你展示的最后一条指令

1 个答案:

答案 0 :(得分:0)

你不能只将convert Date实例设为ms,然后将long插入数据库吗?

所以

cvv.put("time",s.getDate().getTime());