Get entries by month, but not restricted by year
I think a better way would be to add a Preparse field to your Course Dates’ field layout that stores only the month.

https://github.com/aelvan/Preparse-Field-Craft

The code for the preparsedMonth field.

{{ entry.courseStartDate|date('m') }}


With that in place you can drastically simplify your template code and reduce database queries.

{% set categoryParam = craft.request.getParam('month') %}

{% set allDates = craft.entries({
    section: 'courseDates',
    courseStartDate: '&gt;= ' ~ now|date('c'),
    preparsedMonth: categoryParam ? '%02d'|format(categoryParam) : null,
    order: 'courseStartDate',
    limit: null,
}) %}