Answer the question
In order to leave comments, you need to log in
How to write a query to fetch data by time?
Good day to all. There is a table: {id, temperature, humidity, date}. It stores temperature, humidity and date + time (datetime type). Moreover, the weather data is stored in the table every hour. Example: {"id" => 1, "temperature" => 26, "humidity" => 45, "date" => "2014-10-16 12:00:00"}. Help write a query that would return weather and humidity data in the time range from 12:00:00 to 13:00:00 for a week. The range is because there is no such accuracy, the program can record data at 12:00:05. Should be 7 lines. Thanks in advance.
Answer the question
In order to leave comments, you need to log in
SELECT * FROM `mytable`
WHERE
( DATE(`date`) BETWEEN "2014-10-13" AND "2014-10-19" )
AND
( TIME(`date`) BETWEEN "12:00:00" AND "13:00:00" )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question