My query should include the following:
- Everything that starts between 2018-03-04 and 2018-03-10
- Everything that is due between 2018-03-04 and 2018-03-10
- Everything that the period of start_task and due_date falls within 2018-03-04 and 2018-03-10
Answer:
So you are just missing anything where the start - due task date period spans the week you are checking? You should try this:
SELECT
*
FROM
`tasks` tasks
WHERE
(
(`start_task` >= '2018-03-05 00:00:00' and `start_task` <= '2018-03-11 23:59:59')
OR (`due_date` >= '2018-03-05 00:00:00' and `due_date` <= '2018-03-11 23:59:59')
OR (`start_task` <= '2018-03-11 23:59:59' and `due_date` >= '2018-03-05 00:00:00')
)
SELECT
*
FROM
`tasks` tasks
WHERE
(
(`start_task` >= '2018-03-05 00:00:00' and `start_task` <= '2018-03-11 23:59:59')
OR (`due_date` >= '2018-03-05 00:00:00' and `due_date` <= '2018-03-11 23:59:59')
OR (`start_task` <= '2018-03-11 23:59:59' and `due_date` >= '2018-03-05 00:00:00')
)