1

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!!

1 Answer 1

2

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';
Sign up to request clarification or add additional context in comments.

7 Comments

Dear I want both dates to be included and it will not work in case user selects both dates as same.
I want two values of dates 2013-04-01 and 2013-04-10 and this query gets values of 2013-04-01 but not getting values of 2013-04-10 it takes values from 2013-04-01 to 2013-04-09
Do you want all the data between these 2 dates or you just want data of these 2 dates?
I want data of 2013-04-01 to 2013-04-10 both dates included a
No, you would be doing some mistake, this query will get you the data from 2013-04-01 to 2013-04-10. Can you echo the query and check what's there in $date_search1?
|

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.