Display only upcoming events / Show all events when archive year is selected

Replace $today = date('Ymd') with

$hour = 0;
$minute = 0;
$second = 0;
$month = (is_month()) ? get_the_date('m') : 1;
$day = (is_day()) ? get_the_date('d') : 1;
$year = get_the_date('Y');

$timestamp = mktime($hour, $minute, $second, $month, $day, $year);

$search_date = date('Ymd', $timestamp);

// echo $search_date;

In your query, replace 'value' => $today, with

 'value' => $search_date,

error code: 523