Cannot create a filter for date range

I have this question where I filter out some data and I have a dashboard which will contain this SQL query and in that database I want to have a date range filter but when I apply one, it did not show me any variables to choose from. So I added the variables {{period_start}} and {{period_end}} however I keep getting various errors when running it.

Syntax error: Unexpected keyword AND at [35:25]", "status": "INVALID_ARGUMENT" }

How can I fix this?

SELECT
	CAST(
        student_id AS STRING
    ) AS student_id,
    student_name,
    (
        CASE
            WHEN teacher_name IS NULL THEN '--------'
            ELSE teacher_name
        END
    ) AS teacher_name,
    class_date,
    start_time,
    end_time,
    class_location as location,
    bootcamp_id,
    course_name,
    (
        CASE
            WHEN student_phone IS NULL THEN '--------'
            ELSE parent_phone
        END
    ) AS student_phone,
    (
        CASE
            WHEN parent_phone IS NULL THEN '--------'
            ELSE parent_phone
        END
    ) AS parent_phone,
    teacher_phone
FROM
    table
WHERE
    class_date BETWEEN [[{{ period_start }}]] AND [[{{ period_end }}]]
    AND class_date IS NOT NULL
    AND class_location LIKE '%New York%'
    AND schedule_cancelled_at IS NULL
    [[ AND {{ctype}} ]]
    [[ AND LOWER(course_name) LIKE CONCAT('%', LOWER({{course_name}}), '%') ]]
    [[ AND LOWER(class_location) LIKE CONCAT('%', LOWER({{location}}), '%') ]]
    [[ AND LOWER(student_name) LIKE CONCAT('%', LOWER({{student_name}}), '%')]]
ORDER BY 
    start_time, bootcamp_id

Not certain but I suspect what's happening is the way the query is written the START is optional and the END is optional - if no values are set they are omitted form the query. So if you only set a start date your query would read:

"WHERE class_date BETWEEN [[{{ period_start }}]] AND
AND class_date IS NOT NULL"

A field filter might be a better fit for what you're trying to accomplish: