我有这个代码。

 Query q = session.createQuery("FROM SugarLevels WHERE identification = :identification AND date_submitted BETWEEN :startDate AND :endDate ORDER BY date_submitted ASC");
        q.setParameter("identification", identification.toUpperCase());
        q.setParameter("startDate", startDate);
        q.setParameter("endDate", endDate);


但是将出现错误ERROR:运算符不存在:date> =字符变化
我试着做

 Cast(:startDate as DATE)


但仍然是一个错误。有人知道如何将参数转换为最新的吗?

最佳答案

Query q = session.createQuery("FROM SugarLevels WHERE identification = ? AND date_submitted BETWEEN ? AND ? ORDER BY date_submitted ASC");
q.setParameter(identification.toUpperCase());
q.setParameter(startDate);
q.setParameter(endDate);


也许您可以改用上面的代码。

08-28 06:18