How to use BETWEEN in CakePHP — Quick Slice | CakePHP blog

Pssst… Wanna know how to use a SQL BETWEEN statement in CakePHP without having to use an anonymous function? Here 'ya go.

$Query = $Table
->find()
->where([
'date BETWEEN :start AND :end'
])
->bind(':start', '2020-01-01', 'date')
->bind(':end', '2020-12-31', 'date');

( Shamelessly stolen from Stack Overflow)

Hope you enjoyed your slice of Cake 🍰

Originally published at https://cakephp.blog on December 2, 2020.

--

--