I have a table with two columns that are "date" type: date1 and date2.
date1 CAN´T be null but date2 CAN be null
I have the following query:
SELECT
*
FROM table1
WHERE date1 BETWEEN "2021-01-01" AND "2021-12-31"
How can I add a conditional part in where clause, that if date2 IS NOT NULL, apply the following restriction/condition AND date2 BETWEEN "2021-01-01" AND "2021-12-31"