title: Athena- Cannot check if varchar is BETWEEN date and date
body: <p>I created a partition projection in Athena named 'paritiondate', which contains date information in the format <code>2022/01/01</code>.</p>
  <p>I'm running the following query in Athena (via a grafana plugin) which make use of a grafana/athena macro $__dateFilter. The macro is necessary because it detects the date range in Grafana and updates the BETWEEN clause in the Athena query accordingly:</p>
  <p><code>SELECT ssl_protocol, count (*) FROM alb_logs_partition WHERE $__dateFilter(partitiondate) LIMIT 5</code></p>
  <p>The resulting raw query received by Athena is:</p>
  <p><code>SELECT ssl_protocol, count (*) FROM alb_logs_partition WHERE partitiondate BETWEEN date '2022-01-10' AND date '2022-01-11' LIMIT 5</code></p>
  <p>However, I'm receiving the following error:</p>
  <pre><code>error querying the database: SYNTAX_ERROR: line 1:62: Cannot check if varchar is BETWEEN date and date.
  </code></pre>
  <p>So my understanding is that Athena is rejecting the partitiondate value as it's a varchar, and not date.</p>
  <p>I've tried to find a workaround in an attempt to convert it into a date format using date_parse. For example I tried:</p>
  <p><code>SELECT ssl_protocol, count (*) FROM alb_logs_partition WHERE $__dateFilter(date_parse(partitiondate, '%Y/%m/%d')) LIMIT 5</code></p>
  <p>However, the macro cannot handle this and throws an error.</p>
  <p>Is there any other way I can modify the query to convert partitiondate from a varchar into a format Athena/Presto understands, before then using the value in the $__dateFilter macro?</p>