Karem Karem - 2 months ago 12
MySQL Question

SQL between dates including start and end dates

So I have this:

(CURDATE() BETWEEN start_date AND end_date)


Works fine.

But when the
CURDATE()
is 2011-12-02 and the
end_date
is 2011-12-02 will it grab the row?

E.g my start_date is 2011-12-01 00:00:00 and my end date is 2011-12-02 23:59:59

So it only works when the date is between but not if it's ON the
end_date
itself.

Or maybe it should check for the time too, because it still needs to be selected with this query when it's 2011-12-02 15:30:00 for example.

How can I do this?

Answer

Well, you could try

CURDATE() BETWEEN start_date AND DATE_ADD(end_date, INTERVAL 1 DAY)
Comments