Level 22
Nevermind guys I found the answer I just needed to add
->toDateTimeString():
3 likes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm trying to get the data between 2 dates.
and this code returns 0 results
return Model::whereBetween('created_at', [$this->carbon->startOfWeek(), $this->carbon->endOfWeek()])->get();
this is the query statement it creates when I use toSql();
select * table where created_at between ? and ?
but this query works
return $this->appointment->whereRaw('`created_at` between "' . $this->carbon->startOfWeek() . '" and "' . $this->carbon->endOfWeek() . '"')->get();
this is the query statement it creates when I use toSql();
select * table where created_at between "2017-07-31 00:00:00" and "2017-08-06 23:59:59"
I don't get why the first one doesn't work but doing whereRaw works but they have the same query statement.
Its exactly the same and its bothering me.
is this a bug?
Nevermind guys I found the answer I just needed to add
->toDateTimeString():
Please or to participate in this conversation.