I have following table structure
id date time discount
------------------------------------------------------
1 2015-08-10 09:30:00 50%
2 2016-04-15 14:00:00 30%
3 2018-01-25 18:15:00 75%
4 2018-11-19 11:45:00 45%
I want to query this table to find the discount amount on specific date;
expected result;
if I query for a date between 2015-08-10 09:30:00 - 2016-04-15 13:59:59 it should result 50%
for a date between 2016-04-15 14:00:00 - 2018-01-25 18:14:59, should result 30%
example:
Query to this table for date
2016-01-10 08:00:00should result50%
I have searched through SO & Google but couldn't find a solution for my case;
Tried a query for my example like
SELECT * FROM discounts WHERE date<='2016-01-10' AND time<='08:00:00'
ORDER BY date DESC LIMIT 1
but no luck!
Any help is really appreciated.