Answer the question
In order to leave comments, you need to log in
What is the correct way to get data for today/tomorrow, etc.?
There is a table
Events
id title date date_to
date_to - by default NULL
You can add events only for one day or for a period from some date to some, now the questions are - did I correctly make a request to select events for today/tomorrow/week ? Doesn’t leave the feeling that you can somehow turn it more concisely)SELECT * FROM events e
WHERE e.date = CURDATE() OR (e.date <= CURDATE() AND e.date_to >= CURDATE())
WHERE e.date = DATE_ADD(CURDATE(), INTERVAL 1 DAY) OR (e.date <= CURDATE() AND e.date_to >= CURDATE());
WHERE (e.date BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 1 WEEK)) OR (e.date <= CURDATE() AND e.date_to >= CURDATE());
Answer the question
In order to leave comments, you need to log in
And why is it not recommended to store the date in seeing such a normal number and choose the banal <= ?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question