我正在尝试获取从现在到大约一周前的记录,但我收到错误: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)
答案 0 :(得分:1)
为什么不使用标准或查询?
Campaigns.where{date <= new Date() && date > new Date() -7}.list()