Answer the question
In order to leave comments, you need to log in
How to make such a SQL query?
It is necessary to make request in which records which are intersected by the periods will get to selection.
For example, if I am looking for records from 2015-10-05 to 2015-10-10, then the second line will fall into the selection (see picture), it should also fall if I am looking for from 2015-10-15 to 2015-10-20, For example.
Answer the question
In order to leave comments, you need to log in
from <= end_date and to >= start_date
all cases seem to be covered
here is an example but it is MS SQL
ALTER Procedure [dbo].[Procedure_Name] (
@SelectByDate1 date = null,
@SelectByDate2 date = null
) as
select *
from Table_Name
where
P_Date >= coalesce(@SelectByDate1, p_Date)
and P_Date <= coalesce(@SelectByDate2, p_Date)
order by p_date desc
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question