I have a table which contains start and end dates of rooms. I wrote this SQL:
SELECT ic.invoice_id,
pccr.room_name,
DATEDIFF(end, start) AS 'Total Days',
pccr.start,
pccr.end,
FROM partners_campuses_courses_rooms AS pccr
JOIN invoices_courses AS ic ON pccr.course_id = ic.course_id
JOIN invoices i on ic.invoice_id = i.invoice_id
WHERE pccr.deleted_at IS NULL
AND pccr.end BETWEEN '2022-12-01' AND '2022-12-31'
The rooms are active between these dates. But, when I filter like this,
SELECT ic.invoice_id,
pccr.room_name,
DATEDIFF(end, start) AS 'Total Days',
pccr.start,
pccr.end,
FROM partners_campuses_courses_rooms AS pccr
JOIN invoices_courses AS ic ON pccr.course_id = ic.course_id
JOIN invoices i on ic.invoice_id = i.invoice_id
WHERE pccr.deleted_at IS NULL
AND pccr.end BETWEEN '2022-12-01' AND '2022-12-30'
I have no results. These dates are like an array:
dates = ['2017-01-01', '2017-01-02', '2017-01-03', ... , '2022-12-30', '2022-12-31']
So, you can see that room is active on 2022-12-30 but I can't get it. How can I do that?
Hope that I express myself well.
