Sadique Hassan
Sadique Hassan

Reputation: 17

php & mysql: How to get values between two dates including both of them

I need to to get values between two dates including both of them. And is it possible to get values of one date if user selects both dates as same?

I have date column as date and time i am using code as :

select * 
from tbl_issue 
where issue_on>='$date_search' 
    and issue_on<='$date_search1' 
    and item_name='$item_id';

$date_search1 = substr($date_search1,8,2).substr($date_search1,4,4).substr($date_search1,0,4);

The result of this i am getting is between these dates but i wants including both of them.

Help!!

Upvotes: 1

Views: 241

Answers (1)

Indian
Indian

Reputation: 111

You can change your query to this. This will get you the expected result:

select * from tbl_issue where (issue_on between '$date_search' and '$date_search1') and item_name='$item_id';

Upvotes: 2

Related Questions