我有这段代码。
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)
但仍然是错误。任何人都知道如何将参数转换为日期?
答案 0 :(得分:1)
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);
可能是您可以使用上面的代码。