VVB
VVB

Reputation: 7641

How to write between clause for from & to dates for createCriteria in grails?

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?

Upvotes: 2

Views: 7431

Answers (1)

cfrick
cfrick

Reputation: 37033

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)

Upvotes: 1

Related Questions