Answer the question
In order to leave comments, you need to log in
How to make a database query and select the maximum and minimum value?
Guys help me figure it out. I make a selection of temperatures from the database - for the current day in segments of 3 hours. Like this (probably you can somehow optimize the query, I will be grateful for the comments)
//данные на сегодня - на временных отрезках, например today0_3 - сегодня с нуля часов до 3 часов итд.
$today0_3 = \App\Models\Timer::where('time', '>=', date('Y-m-d').' 00:00:00')->where('time', '<=', date('Y-m-d').' 03:00:00')->get();
$today3_6 = \App\Models\Timer::where('time', '>=', date('Y-m-d').' 03:00:00')->where('time', '<=', date('Y-m-d').' 06:00:00')->get();
$today6_9 = \App\Models\Timer::where('time', '>=', date('Y-m-d').' 06:00:00')->where('time', '<=', date('Y-m-d').' 09:00:00')->get();
$today9_12 = \App\Models\Timer::where('time', '>=', date('Y-m-d').' 09:00:00')->where('time', '<=', date('Y-m-d').' 12:00:00')->get();
$today12_15 = \App\Models\Timer::where('time', '>=', date('Y-m-d').' 12:00:00')->where('time', '<=', date('Y-m-d').' 15:00:00')->get();
$today15_18 = \App\Models\Timer::where('time', '>=', date('Y-m-d').' 15:00:00')->where('time', '<=', date('Y-m-d').' 18:00:00')->get();
$today18_21 = \App\Models\Timer::where('time', '>=', date('Y-m-d').' 18:00:00')->where('time', '<=', date('Y-m-d').' 21:00:00')->get();
$today21_24 = \App\Models\Timer::where('time', '>=', date('Y-m-d').' 21:00:00')->where('time', '<=', date('Y-m-d').' 24:00:00')->get();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question