You need to choose by the amount of date and time
SELECT * FROM HistoryReaders WHERE (DateReaders BETWEEN "2018-08-30" AND "2018-08-31") AND (DateReaders + TimeReaders BETWEEN "2018-08-30 04:00:00"AND "2018-08-31 13:00:00")
Condition
(DateReaders BETWEEN "2018-08-30" AND "2018-08-31")
necessary to initially substantially limit the sample. If your DateReaders field DateReaders indexed, we first do a quick sample of the indexed field, and then we finish it.
If there is no index on the DateReaders field, then the condition is not necessary. Anyway there will be a full search of records.
In general, the separation of the date and time fields is 90% bad architecture. If you do not need samples for a certain time for each day, then these fields should be combined into one field of type TIMESTAMP
(DateReaders = "2018-08-31" AND TimeReaders >= "04:00:00") AND (DateReaders = "2018-08-31" AND TimeReaders <= "13:00:00")you select only one date - 20180831. For what period of time do you need to select data? - Novitskiy Denis(DateReaders = "2018-08-31" AND TimeReaders >= "04:00:00") AND (DateReaders = "2018-08-31" AND TimeReaders <= "13:00:00")- Novitskiy Denisor. That's it -SELECT * FROM HistoryReaders WHERE (DateReaders BETWEEN "2018-08-30" AND "2018-08-31") OR ((DateReaders = "2018-08-30" AND TimeReaders >= "04:00:00") AND (DateReaders = "2018-08-31" AND TimeReaders <= "13:00:00"))- Novitskiy Denis