Hello all. First time posting here.
I have an Alteryx workflow with two inputs:
1. Excel file containing a list of dates
2. ODBC Input with SQL Query
I am attempting to create a workflow that first, identifies the minimum and maximum dates within the Excel file. Thereafter, I am looking to leverage those two date values to replace two date placeholders within the SQL query before running.
The workflow currently identifies the two date values in the following format: (as outputs of a select tool)
StartDate EndDate
2018-02-02 2019-02-03
The SQL query looks like this: (looking to replace 'StartDate' and 'EndDate' with outputs of previous Select tool)
Select *
From 'dummytable'
WHERE DateField >= 'StartDate'
AND DateField <= 'EndDate'
Does anyone have a solution for this? Thank you very much in advance.
Solved! Go to Solution.
An workflow example
Insert the macro after the select tool and place the container with input data in the macro.
Hi GreysonP
Pretty simple solution for your issue. You'll want to have that data set with the start and end date feed into a dynamic input tool where you have your custom SQL script. In the modify SQL Query part, you'll add 2 separate "SQL: Update WHERE Clause" and just select the string of text to replace in both conditions. Just make sure you're consistent with the string you want to replace. In my workflows I will typically put a data value of '9999-12-31' or something like that to always replace in the dynamic input tool.
Happy solving!
Thank you for your help! This worked. Much appreciated.