Forum Discussion
Anonymous
3 years agoNot applicable
Use a date query in parameters
Is it possible to create an Oracle SQL query in parameters that would be "last 12 months"?
I'm pulling in multiple tables with an Oracle query that would look like:
let
query = "SELECT * FROM TABLE WHERE DATE_COLUMN >= TO_DATE('" & RangeStart & "', 'DD/MM/YY')",
Source = Oracle.Database("abcd.com", [HierarchicalNavigation=true, Query=query])
in
SourceI created the parameter that currently has "1/4/22" for April 1, 2022.
Is it possible to create a parameter that dynamically changes to "last 12 months"?
I know, I could just have my SQL query be something like this:
WHERE
DATE_COLUMN BETWEEN TRUNC(ADD_MONTHS(SYSDATE,
-12),
'MONTH')
AND TRUNC(SYSDATE,
'MONTH') -1but I have multiple tables and I don't want to have to go into each query and manually update the date range.
1 Reply
- ppm1Solution Sage
Do you need to use hand-authored queries? Why not just connect to your source and use the power query experience to filter your data with the date filter options (that include a relative option). It should "fold" back to your source with similar queries.
Pat