i am trying to pull records that are 7 days old only , not older or earlier. But its not working, i'm using Carbon.
->where(DB::raw('date(AppDate)'), Carbon::now()->subDays(7))
You can use whereDate
for that :
->whereDate('created_at', Carbon::now()->subDays(7))
->get();
In the documentation :
The whereDate method may be used to compare a column's value against a date
PS : Since Laravel 5.3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With