Try it with whereRaw
$on_hire = DB::table('stock_booking')
->whereRaw('DATE_ADD(from, INTERVAL 1 DAY) <= NOW()')
->where('to', '>=', now()->toDateString())
->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have the following command which searches the 'from' column and returns rows which the 'from' column is before today and 'to' is after today:
$on_hire = StockBooking::where('from','<=',Carbon::now())->where('to','>=',Carbon::now()->format('Y-m-d'))->get();
This is all working ok, but it's changed so that I need to use the 'from' column plus one day instead of just 'from'. I have the below raw sql statement but this doesn't seem to return any rows:
$on_hire = DB::table('stock_booking')
->where(DB::raw('DATE_ADD(from, INTERVAL 1 DAY)'), '<=', Carbon::now())
->where('to','>=',Carbon::now()
->format('Y-m-d'))
->get();
Could you possibly tell me where I've gone wrong please?
Or maybe it will work with backsticks
$on_hire = DB::table('stock_booking')
->whereRaw('DATE_ADD(`from`, INTERVAL 1 DAY) <= NOW()')
->where('to', '>=', now()->toDateString())
->get();
Please or to participate in this conversation.