Forum Discussion
Pass a value to ODBC data access command on refresh
- 4 years ago
This can be done with the query parameter in Power Query Editor. Have you tried it?
Create a parameter query (Power Query) (microsoft.com)
Parameters - Power Query | Microsoft Docs
And you can use the following M code to get the date 7 days ago. I have formatted it to be consistent with the datetime format in your SQL statement.
= DateTime.ToText(Date.AddDays(DateTime.LocalNow(),-7),[Format="yyyy-M-d'T'00:00:01"])So you could try
Source = Odbc.Query("dsn=MyData", "SELECT * FROM core-appliance-214519.production.socket_readings_v202106 where (device_id='ide_production_142' ) and read_at>= ' & DateTime.ToText(Date.AddDays(DateTime.LocalNow(),-7),[Format="yyyy-M-d'T'00:00:01"]) & '"),Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
This can be done with the query parameter in Power Query Editor. Have you tried it?
Create a parameter query (Power Query) (microsoft.com)
Parameters - Power Query | Microsoft Docs
And you can use the following M code to get the date 7 days ago. I have formatted it to be consistent with the datetime format in your SQL statement.
= DateTime.ToText(Date.AddDays(DateTime.LocalNow(),-7),[Format="yyyy-M-d'T'00:00:01"])
So you could try
Source = Odbc.Query("dsn=MyData", "SELECT * FROM core-appliance-214519.production.socket_readings_v202106 where (device_id='ide_production_142' ) and read_at>= ' & DateTime.ToText(Date.AddDays(DateTime.LocalNow(),-7),[Format="yyyy-M-d'T'00:00:01"]) & '"),
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.