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

FallOutBoi's avatar

How to select distinct date by day?

Hi guys, i am having a trouble here trying to get created_at from a database table. For example

2019-06-10 14:07:47
2019-06-10 15:07:47
2019-06-10 16:07:47
2019-06-10 17:07:47
2019-06-10 18:07:47

I have these dates inside my created_at column. I want to get distinct records based on the day.

$t = DB::table('table')
            ->where('created_at','>',$start_date)
            ->where('created_at','<',$end_date)
            ->distinct(?)
            ->first();

Any way i can achieve this?

0 likes
1 reply

Please or to participate in this conversation.