Quantcast
Channel: Data Preparation & Blending discussions
Viewing all articles
Browse latest Browse all 4999

Automate where condition in a Sql query with system date

$
0
0

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!

 


Viewing all articles
Browse latest Browse all 4999