I have the following SQL query
SELECT
users.username, users.first_name, users.last_name, users.description,
sprints.sprint_start_date, sprints.sprint_end_date, users.user_id
FROM
sprints
INNER JOIN
sprints_vs_users ON sprints.sprint_id = sprints_vs_users.sprint_id
RIGHT OUTER JOIN
users ON sprints_vs_users.user_id = users.user_id
WHERE
(sprints.sprint_start_date BETWEEN CONVERT(datetime, @startdate, 103)
AND CONVERT(datetime, @enddate, 103))
AND (sprints.sprint_end_date BETWEEN CONVERT(datetime, @startdate, 103)
AND CONVERT(datetime, @enddate, 103))
If we were to declare @startdate
variable as 26/11/2015
and declare @enddate
variable as 03/12/2015
and if we use an example of a sprint_start_date
of 27/11/2015
and sprint_end_date
of 4/12/2015
I want the sprint with those sprint start and end dates to appear in the result as the sprint dates occur during the selected variable dates. However at the moment, the query does not display this result which I think is due to the sprint_end_date
not appearing between the 26/11/2015
and 03/12/2015
although I am not sure how to fix this, so any help would be much appreciated.