简体   繁体   English

从 Excel 单元格引用到 ODBC SQL PowerQuery 的传递日期

[英]Pass dates from an Excel cell reference into ODBC SQL PowerQuery

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.我有几个 MySQL 查询,包括一些聚合但不一定在结果中返回日期的查询,这些查询具有硬编码到查询中的日期或日期范围。 I've loaded these into separate Excel worksheets through ODBC to output the results.我已经将这些加载到单独的 Excel 工作表中,通过 ODBC 到 output 结果。 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:我的 SQL 谓词的日期部分如下所示:

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.我希望能够直接在单元格中更改日期,而不需要 VBA,然后单击刷新以返回正确的结果。 Thanks!谢谢!

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.您可以将单元格值读入 PowerQuery ,然后在查询中使用这些单元格值,类似于我在链接帖子中给出的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM