@ligonsker You may try this:
$now = Carbon::now();
$query = MyModel::query()
->whereRaw('CONCAT(`date`, " ", `time`) >= ?', [$now->toDateTimeString()])
->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I have 2 separate columns for the date: the date itself in YYYY-mm-dd format, and a time column in time(7) datatype, for example 11:15:10.0000000
How can I check for rows that are in the future?
I can get the first part, for the day itself:
MyModel::where('date', '>=', Carbon::today())->get()
But when I try adding the time it doesn't work:
MyModel::where('date', '>=', Carbon::today())->where('time', '>', Carbon::now()->format('H:i'))->get()
because they are separate and now even though the date is in the future, the time is separate so there may be a situation where the time doesn't match. So I somehow need to have both the date and the time related to it in the future, not separately
Ty
Please or to participate in this conversation.