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

yigitozmen's avatar

WhereBetween does not include end date

I want to get records between two dates and i use this:

         ->whereBetween('created_at', [$start, $end])

this eloquent includes $start date records but does not include $end date records. How can i fix that? Thank you.

0 likes
3 replies
michaeldyrynda's avatar
Level 41

Are you passing a date (YYYY-MM-DD) or date time (YYYY-MM-DD HH:MM:SS)?

whereBetween is sugar for the database's BETWEEN keyword. If you need to include start and end dates, be explicit about the times i.e. YYYY-MM-DD 00:00:00 and YYYY-MM-DD 23:59:59.

The reason it includes the start date and not the end date is because of the implicit time of 00:00:00.

9 likes
bhargav3's avatar

@yigitozmen I know this is an old post. If you don't have an end date, you can try this:

$query->where('created_at', '>=', $startDate);
2 likes

Please or to participate in this conversation.