Reputation: 504
Why its not working if my both value are same I already use with equal operator. User need to select date from & to, if the user select both same date of from & to which is 2017-08-13
it should still display all the dates of 2017-08-13
and unfortunately not working.
SELECT * FROM master_data.speed_of_service where
( trans_time >= '2017-08-13' and
trans_time <= '2017-08-13')
It only work if there are interval between dates
Upvotes: 3
Views: 1123
Reputation: 1269563
If I had to guess, it is because trans_time
has a time component. One easy fix is to extract the date:
SELECT ss.*
FROM master_data.speed_of_service ss
WHERE date(trans_time) >= '2017-08-13' and date(trans_time) <= '2017-08-13';
A better solution would be to add one day to the "to" date:
SELECT ss.*
FROM master_data.speed_of_service ss
WHERE trans_time >= '2017-08-13' AND
trans_time < '2017-08-13' + interval 1 day;
This is better because it still allows the use of an index.
Upvotes: 5