Riyadh Ahmed
Riyadh Ahmed

Reputation: 1299

Search data by date from a database table using PHP?

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?

Upvotes: 0

Views: 579

Answers (1)

Al Amin Chayan
Al Amin Chayan

Reputation: 2500

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'

Upvotes: 3

Related Questions