如何在从&到grails中createCriteria的日期? [英] How to write between clause for from & to dates for createCriteria in grails?

查看:149
本文介绍了如何在从&到grails中createCriteria的日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  def c = TestCase.createCriteria()$ b $我想在两个日期之间使用以下代码获取结果。 b resultss = c.list {
like(testStatus,Dummy)
和{
between(testTime,date1,date2)
}
order('testify','desc')
}

这里我想选择From日期和日期如下

  FROM DATE:'2014-11-07 12:14:03'(date1)
TO DATE:'2015-01-09 08:14:12'(date2)



任何人都可以告诉我怎么做吗?

解决方案

和存在奇怪;首先,无论如何都是默认设置。如果你想明确,然后把语句放入和阻止:

 和{
like( testStatus,Dummy)
(testTime,date1,date2)
}


$ b (testStatus,Dummy)
之间(testTime)

  ,date1,date2)


I want to fetch results between 2 dates using following code.

def c = TestCase.createCriteria()
resultss = c.list {
    like("testStatus", "Dummy")
    and {
        between("testTime", date1, date2)
    }
    order('testified','desc')
}

Here I want to select From Date and To Date like below

FROM DATE : '2014-11-07 12:14:03'(date1)
TO DATE   : '2015-01-09 08:14:12'(date2)

I tried a lot but no luck to get it run.

Can anybody please tell me how to do that?

解决方案

the and there is odd; first of all and is the default anyway. and if you want to be explicit, then put the statements into the and block:

and {
    like("testStatus", "Dummy")
    between("testTime", date1, date2)
}

or just

like("testStatus", "Dummy")
between("testTime", date1, date2)

这篇关于如何在从&到grails中createCriteria的日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆