Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Automate where condition in a Sql query with system date

iRm
6 - Meteoroid

Hi,

I have searched for this topic in the community and am not finding what I am looking for. I am also very new to Alteryx advanced functions and have learned this tool on the job.

 

I have a date field ABC that looks like this: '2017-07-07 00:40:08'

 

This field is being used in a query but currently I am hard coding it. eg. where ABC >= '2017-07-07'. But I want to automate it.

 

I am trying to add a logic to my query to look at current date and subtract 2 months from it. So basically I want to start from July 7th.

 

I researched and found that there is a dynamic input tool that may suit my purposes. I have different things like follows:

 

1. Create a new field Mydate which is defined as DATETIMEADD([DateTimeNow],-60,"DAYS")

3. Then in the query use the following clause:

Where ABC >= Mydate.

 

Is there a better approach to do it ?

 

Thanks so much! This site is awesome with so many helpful/knowledgeable people for beginners like me! Please keep up the good work!

 

3 REPLIES 3
JohnJPS
15 - Aurora

Hi @iRm

What you've described is exactly how I would do it.  The last step is to select the "Modify SQL Query" radio button, and then Add > Replace a Specific String...

scr1.png

and then replace the string "myDate" with the value from your input field "myDate"

sc2.png

Hope that helps!

iRm
6 - Meteoroid

Thank you so much! 

 

 

JohnJPS
15 - Aurora

Sorry for not being clear - it's in the lower portion of the Config Panel for the Dynamic Input.

Labels