jeudi 19 janvier 2017

How to get results not between two dates?

I have two dates that property has been blocked on that two days like start date 2017-01-20 and end end 2017-01-25. Between these two dates property has been blocked. When i search with these two dates except these two dates i want to get the remaining dates.

Here i have tried by searching on google in mysql like

select `pd`.*, `pa`.*
from `property_details` as `pd` left join
     `property_gallery` as `pg`
     on `pg`.`property_id` = `pd`.`property_id` left join
     `property_preblock_details` as `pbd`
     on `pbd`.`property_id` = `pd`.`property_id` left join
     `property_amenity` as `pa`
     on `pa`.`property_id` = `pd`.`property_id`
where `pbd`.`start_date` >= '2017-01-20'  and `pbd`.`end_date` <= '2017-01-25'

and

select pd.*
from `property_details` as `pd` left join
     `property_gallery` as `pg`
     on `pg`.`property_id` = `pd`.`property_id` left join
     `property_preblock_details` as `pbd`
     on `pbd`.`property_id` = `pd`.`property_id` left join
     `property_amenity` as `pa`
     on `pa`.`property_id` = `pd`.`property_id`
 where `pbd`.`start_date` NOT BETWEEN CAST('2017-01-20' AS DATE) and CAST('2017-01-25' AS DATE) AND
       `pbd`.`end_date` NOT BETWEEN CAST('2017-01-20' AS DATE) and CAST('2017-01-25' AS DATE)

But i'm getting results as between dates.

I don't want to get between dates results, i want to get not between dates results.

Please help me out. Thanks in advance.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2jBacAI
via IFTTT

Aucun commentaire:

Enregistrer un commentaire