in reply to Querying Date Ranges with DBIx::Class

I'm not sure if any of this is causing the error you show but there are a couple of things wrong in your code.

In the first case one of your eventdates is clobbered by the other, and you need to change '=<' to '<=':

my @events = $schema->resultset( 'MyTable' )->search({ eventdate => { '>=' => $date1, '<=' => $date2 } });
In the second case 'between' should be '-between':
my @events = $schema->resultset( 'MyTable' )->search({ eventdate => { -between => [ $date1, $date2 ] } });

Replies are listed 'Best First'.
Re^2: Querying Date Ranges with DBIx::Class
by phildeman (Scribe) on Sep 09, 2014 at 12:41 UTC

    Thanks for your feed back.

    Regarding the first example, I made the correction and I still got the same error. With the second example, I typed the code into the textarea of this form, rather than copying and pasting. So, in my actual code I do have the hyphen prefixed to between.

    Just another thought, $date1 and $date2 are form values. Should I be converting those values into DateTime objects, then passing it in to the query (in the first example)?