Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Automaticaly determine dates to filter

tushar44
6 - Meteoroid

Hi there,

 

Objective:

 

I have past 2-3 year data in my input everytime. I want alteryx to filter past 12 months data only (past 12 months from today's date) whenever I run my workflow. I want to make sure that alteryx automatically determine today's date and calculate what past 12 months date would be and filter the data accordingly. Is there any way I can do that?

 

Thanks in advance!

2 REPLIES 2
afv2688
16 - Nebula
16 - Nebula

Hello @tushar44 ,

 

You can use for that the DateTimeNow() function. What you could establish on the filter would be something like this:

 

 

[DateField] >= ToDate(DateTimeAdd(DateTimeNow(),-1,'year'))

 

 

This will calculate first todays date, after that it will subtract a whole year and filter only the dates that are in that span.

 

Regards

MarqueeCrew
20 - Arcturus
20 - Arcturus

@afv2688 ,

 

[DateField] >= ToDate(DateTimeAdd(DateTimeNow(),-1,'year'))

 Alex, I highly recommend DateTimeStart() instead of DateTimeNow(). 

all comparisons are the same.  This function uses 1 date for all comparisons.  If I'm the event the job runs over midnight you will get the same result. 

@tushar44 ,

 

 the fixed date -1 year will get different results if re-run on a different day.  You might consider adding a detour to the workflow to allow the use of a fixed date in case issues exist. 

cheers,

 

 mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Labels