Using MySQL how do I select data between two dates if the dates are in separate columns -
in database, have column check-in date , column check-out date. need select every row has check-in date <= 7/30/2017 , check-out date >= 7/30/2017.
this code have now:
select * `v_reservation_records` cast(checkin date) <= '7/30/2017' , cast(checkout date) >= '7/30/2017'
here example date db:
2018-09-18
when run query, not results, know have check-in date equal 7/30/2017. missing? or there easier way accomplish goal?
assuming casting valid values date
should convert literal date
select * `v_reservation_records` cast(checkin date) <= str_to_date('7/30/2017' , '%d/%m/%y') , cast(checkout date) >= str_to_date('7/30/2017' , '%d/%m/%y')
and can use between
select * `v_reservation_records` str_to_date('7/30/2017','%d/%m/%y') between cast(checkin date) , cast(checkout date)
Comments
Post a Comment