Question: Lets say, i have a "Book" class with field "availableOn"(as shown below). 

```
class Book {
    String availableOn;
}

```

The fields holds values 

* "All days" or
* String representation of a date. For example "13/06/2012"

How can i get all Books that are available within next two days? The below code would throw an exception ("java.util.Date cannot be cast to java.lang.String")

```
def books = c.list(){
    between('availableOn', new Date(), new Date() + 2)
}

```

PS : Am working on a legacy DB, and so am not suppose to change the schema :(

Answer: 
I think there are 2 problems which the `between` statement will have:

* `availableOn` cannot be converted to a `Date` for comparison when its value is `All days`
* Even when `availableOn` has a date value in it, it is not converted to a `Date` for the comparison

I'd try something along the lines of this:

```
def now = new Date()
def books = Book.findAllByAvailableNotEqual("All days").findAll { book ->
    Date.parse('dd/MM/yyyy', book.availableOn) > now && Date.parse('dd/MM/yyyy', book.availableOn) < now+2
}

```

Clearly, this can be done in a nicer way (adding some methods to the domain class for example), but this should illustrate my idea...
I don't have a criteria based solution, but you can try something like this:

```
Book.executeQuery(
      "select book from Book book where book.availableOn = :availableOn or to_date(book.availableOn, :format) between (:startDate, :endDate) ",
     [availableOn:"All days", format: "dd/MM/yyyy", startDate: startDate, endDate:endDate])

```

The problem with my solution is that this query becomes DB dependent. `to_date` is an Oracle function. You may want to alter this to fit your database