MySQL Forums
Forum List  »  General

Re: MySQL Date Query issue
Posted by: Rick James
Date: March 27, 2009 09:48AM

Possibly related:

What version do you have?

Anyway, the "best" way to deal with your query is one that can effectively use an index:
WHERE Post_date >= ? AND Post_date < DATE_ADD(?, INTERVAL 1 DAY)
where you bind in the desired date in both substitution places.

Then, if you have an index including Post_date, it will consider doing a "range" query.

I use the DATE_ADD (or DATE_SUB) so that I don't have to use 23:59:59, nor have to worry about getting midnight included in two different days.

Options: ReplyQuote

Written By
March 26, 2009 07:24AM
Re: MySQL Date Query issue
March 27, 2009 09:48AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.