I want to subtract days from the db column and then compare it with the current date using DATE_ADD function. Is this possible?
$valid_status_query->whereRaw('DATE_ADD("d",-3, "date_to")', '<=', Carbon::now()->format('Y-m-d'));
For example, if the column date is 2022-07-20 then it should use 2022-07-17 to compare in where clause at the end.
>Solution :
Use it like this:
$valid_status_query->whereRaw("DATE_SUB(date_to, INTERVAL 3 DAY) <= ?", [Carbon::now()->toDateString()]);