Date and Category query with filter

I was going about this the wrong way around. I needed to allow the user to select the date first and then the category.

I also needed to make the dropdown boxes auto select, so that the date search is performed first taking the user to the date archive and then the user can select the category they require.

<form class="my-filter" method="GET" action=""><div class="col-sm-12 text-center">
        <span>Filter Posts by:</span>
      <ul class="list-inline">
     <?php $years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts WHERE post_status="publish" AND post_type="post" ORDER BY post_date DESC");
      $months = $wpdb->get_col("SELECT DISTINCT MONTHNAME(post_date) FROM $wpdb->posts WHERE post_status="publish" AND post_type="post" ORDER BY post_date DESC");?>
        <li>
          <select onChange="window.location.href=this.value">
                <option value="" disabled selected> Date </option>
                    <?php foreach($months as $month) : ?>
                <option value="<?php echo site_url() ."https://wordpress.stackexchange.com/".date('Y') ."https://wordpress.stackexchange.com/".date('m', strtotime($month))?>"> <?php echo '<ul><li class"list-unstyled">' . $month .'</li></ul>';?></option>
                    <?php endforeach; ?>

                    <?php foreach($years as $year) : ?>
                <option value="<?php echo  site_url() ."https://wordpress.stackexchange.com/".$year ?>"><?php echo '<ul><li class"list-unstyled">' . $year .'</li></ul>';?></option>
                    <?php endforeach; ?>    
            </select>
        </li>
        <li>
          <label>
            <select onChange="window.location.href=this.value">
                <option value="category" disabled selected> Category </option>
                    <?php foreach( $categorys as $category ) : ?>
                <option value="?category=<?php echo $category->slug; ?>">
                    <?php echo $category->name; ?>
                </option>
                <?php endforeach; ?>
            </select>
            </label>
        </li>       
      </ul>   
      </div>
    </form>

Now the final url reads

http://mywebsite.com/2015/09/?category=special-events

To make sure that the query finds the category only for that month the $args must include a dynamic date_query like this:

$m = get_the_time('m');
$y = get_the_time('Y');

$args = array(
            'post_type'      => array('post'),
            'post_status'    => 'publish',
            'tax_query'      => $cat_query,
            'orderby'        => 'date',
            'order'          => 'desc',
            'date_query' => array(
    array(
        'year'  => $y,
        'month' => $m,
    ),
),  

);