0

I have a table where a date field (datetime type). Stored data like 2015-12-09 11:33:44 .I have datepicker input field to search data which generated date like 2015-12-09.So how can i search data using the given date.Assume that i have many data with same date but different time.Is this possible to get all matched data with a given date?

1 Answer 1

3

convert your input date in a date range:

$inpute_date = '2015-12-09';
$start_date = $inpute_date . ' 00:00:00';
$end_date = $inpute_date . ' 23:59:59';

And in your condition:

WHERE your_date_col BETWEEN '$start_date' AND '$end_date'
Sign up to request clarification or add additional context in comments.

1 Comment

Just tested my "solution" (using Date()) and yours and ...dang, MyQL really doesn't optimize WHERE Date(d)='...' to use the index on d exactly like it does for d BETWEEN ... AND .... (It does use the index, but without index push down).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.