Answer the question
In order to leave comments, you need to log in
[SQL] Check if one date range lies within another
Good afternoon.
Please help me write a SQL query.
There are two dates.
You need to check that the interval between these data does not fall into the date interval in the database table. And also that the date interval in the table does not fall within the interval between these dates.
Answer the question
In order to leave comments, you need to log in
well, like this
select * from table t
where
not
(
{$fromDate} between t.date1 and t.date2
or
{$toDate} between t.date1 and t.date2
)
</sql>
declare date1 datetime;
declare date2 datetime;
set @date1 = '2010-12-03';
set @date2 = '2010-12-07';
select * from table t where t.date not between @date1 and date2;
`start` < #end AND `reservation`.`end` > #start
Where #start and #end respectively is your range
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question