意外的令牌Interval Groovy

时间:2016-06-29 12:59:13

标签: hibernate grails

我正在尝试获取从现在到大约一周前的记录,但我收到错误:unexpected token: INTERVAL

String query = "SELECT * FROM campaigns where DATE(date) BETWEEN DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND CURDATE()"

def result = Campaigns.executeQuery(query)

error image

1 个答案:

答案 0 :(得分:1)

为什么不使用标准或查询?

Campaigns.where{date <= new Date() && date > new Date() -7}.list()