Answer the question
In order to leave comments, you need to log in
How to formulate a query to the database to select by date range?
There is a table `apartment_dates` that looks like this:
| id | date_from | date_to |
|----|------------|------------|
| 1 | 2017-07-01 | 2017-07-10 |
| 2 | 2017-07-11 | 2017-07-20 |
| 3 | 2017-07-21 | 2017-07-30 |
Answer the question
In order to leave comments, you need to log in
What does cross mean? full entry or partial?
select * from apartment_dates where date_from beetwen '2017-07-05'::date and ' 2017-07-15'::date or date_to '2017-07-05'::date and ' 2017-07-15':: date -- partial
select * from apartment_dates where date_from beetwen '2017-07-05'::date and ' 2017-07-15'::date and date_to '2017-07-05'::date and ' 2017-07- 15'::date --full
C - inclusive
software - exclusive
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question