0
votes

I have several MySQL queries, including some that aggregate but don't necessarily return dates in the results, that have either a date or date range hardcoded into the query. I've loaded these into separate Excel worksheets through ODBC to output the results. Instead of going into the query and editing the source as needed to change the dates, how can I have the 'start' or 'start and end' date(s) of the query be a cell reference on that particular worksheet?

The date part of my SQL predicates look like:

WHERE post.trans_date >= '2020-03-01'

or

WHERE post.trans_date >= '2020-03-01'
AND post.trans_date <= '2020-03-31'

I'd like to just be able to change the dates directly in the cell(s), without VBA, and click Refresh to return the correct results. Thanks!

1

1 Answers

0
votes

You can read cell values into PowerQuery and then use those cell values within your query similarly to the example I give in the linked post.