0

I want to check after my orWhereColumn if planned_completion_date time is at 09:00. planned_completion_date is of timestamp datatype. How can I check this? This is how my query looks like:

$portings = Porting::with('items')
->where('status', AbstractPorting::STATUS_ACCEPTED)
->where(function ($q) {
  $q->where('planned_completion_date', '<=', date("Y-m-d H:i:s", time()));
  $q->orWhereColumn('planned_completion_date', '<', 'first_possible_date');
})->get();
Neavehni
  • 337
  • 1
  • 2
  • 14
  • Does this answer your question? [Laravel eloquent where date is equal or greater than DateTime](https://stackoverflow.com/questions/44266337/laravel-eloquent-where-date-is-equal-or-greater-than-datetime) – Peppermintology Oct 06 '22 at 13:43
  • @Peppermintology Date is not important for me. I only want to check if it is at 09:00 and nothing else. – Neavehni Oct 06 '22 at 13:45

1 Answers1

1

You can try this :

$portings = Porting::with('items')
->where('status', AbstractPorting::STATUS_ACCEPTED)
->where(function ($q) {
  $q->where('planned_completion_date', '<=', date("Y-m-d H:i:s", time()));
  $q->orWhereColumn('planned_completion_date', '<', 'first_possible_date');
  $q->where(DB::raw("DATE_FORMAT(planned_completion_date, '%H:%i')"), '=', '09:00');
})->get();
ybert
  • 852
  • 10
  • 18