如果列中有日期和时间,如何检查当前日期?

时间:2019-04-05 10:33:36

标签: sql grails gorm

无论日期如何,我都应如何匹配今天/当前日期,列的日期为(yyyy-mm-dd HH:mm:ss),例如(2019-04-05 16:00:00.0) 使用Grails GORM findBy方法?

1 个答案:

答案 0 :(得分:2)

您可以在之间使用。

def today = new Date().clearTime()
def tomorrow = use( TimeCategory ){ today + 1.day }.clearTime()

YourDomain.findByYourDateBetween( today, tomorrow )

可能更适合findAllBy。