sqlite查询,datetime有关问题

sqlite查询,datetime问题

"select * from health_advice where adviceTime between datetime(history,'localtime') and datetime(history,'start of day','localtime','+1 month')"


history是一个string型,记录的是时间信息。sqlite报错说没有这一列,那就是sqlite把它当成了表中的某一列,那这个地方应该如何来使用这个变量呢

------解决方案--------------------
难道你的sql语句拼的不对?
		String str_sql = "select * from health_advice where adviceTime between datetime('"
+ history
+ "','localtime') and datetime('"
+ history
+ "','start of day','localtime','+1 month')";

------解决方案--------------------
引用:
Quote: 引用:

难道你的sql语句拼的不对?
		String str_sql = "select * from health_advice where adviceTime between datetime('"
+ history
+ "','localtime') and datetime('"
+ history
+ "','start of day','localtime','+1 month')";

按照你这个我没找到记录,但是我把history换成字符串常量"2013-05-01 00:00:00"就可以查到数据

那你把我上面的history上面的''去了试试
------解决方案--------------------
				String str_sql = "select * from health_advice where adviceTime between datetime("
+ history
+ ",'localtime') and datetime("
+ history
+ ",'start of day','localtime','+1 month')";

------解决方案--------------------
引用:
Quote: 引用:

难道你的sql语句拼的不对?
		String str_sql = "select * from health_advice where adviceTime between datetime('"
+ history
+ "','localtime') and datetime('"
+ history
+ "','start of day','localtime','+1 month')";