-1

I am using this query to get all the dates between 2 dates:

$getDates="SELECT daily_rate_date FROM daily_rates  WHERE daily_rate_date BETWEEN '".$checkOut."' AND '".$departureDate."' AND daily_rate_reservation=$reservationId;";

The thing is that if for example $checkOut = 03-03-2021 and $departureDate = 07-03-2021, I get the dates:

04-03-2021
05-03-2021
06-03-2021

but i also need the $checkOut date too to be included (but not the $departureDate) :

03-03-2021 
04-03-2021
05-03-2021
06-03-2021

How can I accomplish that?

2

2 Answers 2

0

then change your query to:

$getDates="SELECT daily_rate_date FROM daily_rates  
           WHERE daily_rate_date >= '".$checkOut."' 
           AND   daily_rate_date < '".$departureDate."' 
           AND   daily_rate_reservation=$reservationId;";
Sign up to request clarification or add additional context in comments.

Comments

0

You could use >= and < operators instead of between for you use case.

$getDates="SELECT daily_rate_date FROM daily_rates  WHERE daily_rate_date >= '".$checkOut."' AND < '".$departureDate."' AND daily_rate_reservation=$reservationId;";

Comments

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.