I have query like below
SELECT * FROM programs where startTime between now() and now() + INTERVAL 1 DAY;
Is it possible to write query with time between now and midnight of today in MySQL?
Something like below
SELECT * FROM programs where startTime between now() and now() + midnight 12;
I suggest you always use clopen (closed-open) intervals for dates and times comparisons.
BETWEENmeans closed intervals (from both sides). A very good explanation is in @Aaron Bertrand’s blog post: What do BETWEEN and the devil have in common?. Here’s a way to write the query: