我的Grails应用程序中有一个域类,如下所示:
class Event {
Date date
}我想写一个条件查询,选择某年某月发生的事件,有什么建议吗?
谢谢,唐
发布于 2010-10-18 01:34:32
您可能只需要使用between
def firstDayOfMonthInYear, lastDayOfMonthInYear;
/* set the two values using Calendar or some other mechanism */
Event.withCriteria {
between('date', firstDayOfMonthInYear, lastDayOfMonthInYear)
}我不确定between的包容性-如果它不是两端的包容性,你可能需要调整你的开始/结束日期。
https://stackoverflow.com/questions/3953902
复制相似问题