Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

pavlen's avatar

Using mysql DATE function inside query

Hi.

I have this query :

$pagination =Orders::where('created_at' ,'=' ,'2015-07-24 07:22:00')->paginate(11);

and it work fine, now I need a specific option,to check only date from timestamp. Sql query will be :
SELECT * FROM orders WHERE date( created_at ) = '2015-07-24'

NOw, how to implement date( created_at ) in Laravel query ?

Tnx

0 likes
6 replies
pmall's avatar
Order::whereRaw('date(created_at) = ?', [$date])->get();
pavlen's avatar

Yeah,this work,I try that,but is then posibility to use paggination ?

pmall's avatar

Why wouldnt it be possible ?

Order::whereRaw('date(created_at) = ?', [$date])->paginate();
pavlen's avatar

I try just like you:

and get this error:

TokenMismatchException in compiled.php line 2440

pmall's avatar

This is totally unrelated with the query

pavlen's avatar

Tnx for time! I will inform here whene solve problem,tnx again!

Please or to participate in this conversation.