NutzCN Logo
问答 请问关于 Cnd 设置时间的问题
发布于 2348天前 作者 qq_412bd180 1708 次浏览 复制 上一个帖子 下一个帖子
标签:

代码如下

Cnd tmp = Cnd.where("stationTypeId", "=", stationtypeid);
//时次
if(!shiciGtVal.equals("")&&!shiciLtVal.equals("")){

if(shiciGtVal!=shiciLtVal){
	tmp.and("eventtime", ">=",shiciGtVal);
	tmp.and("eventtime", "<=",shiciLtVal);
}else{
	tmp.and("eventtime", "=",shiciGtVal);
}
}

shiciGtVal 和 shiciLtVal 传入的是字符串
报异常:
operator does not exist: timestamp without time zone >= character varying

请问如何解决

8 回复

转Date对象

PS: 字符串对比用 != 是要死的

sql 语句

SELECT * FROM t_push_log  
WHERE stationTypeId=1 
AND eventtime >= '2017-10-04 01:00:00' 
AND eventtime <= '2017-10-05 01:00:00' 
ORDER BY taskId DESC   
LIMIT 15 OFFSET 0 

在JDBC里面的语句跟数据库控制台的执行效果是有差异的

if(!shiciGtVal.equals(shiciLtVal)){

那么代码如何修改 谢谢

转Date对象

tmp.and("eventtime", ">=",new Date()); ?

另外可以适用LocalDateTime吗?

LocalDateTime没继承Date吧

new SimpleDateFormat("....").paser 才能转Date对象啊

添加回复
请先登陆
回到顶部