1

我有这个代码。

 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: operator does not exist: date >= character varying 我试过做

 Cast(:startDate as DATE)

但仍然是一个错误。任何人都知道如何将参数转换为日期?

4

1 回答 1

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);

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

于 2013-01-11T08:30:51.263 回答