Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Community is experiencing an influx of spam. As we work toward a solution, please use the 'Notify Moderator' option on the ellipsis menu to flag inappropriate posts.
Free Trial

Alteryx Designer Desktop Discussions

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

Filter for dates after December 31 of the previous year

Travis_Ratliff
8 - Asteroid

Hi All,

Can somebody help me with my scenario?

I have one input as a database, with an example below. 

 

Example: 

Input sample

IDCompany_namecontract_agreementDateQuantityPrice
T1McDonalds678292022-03-31453.25
T2Burger King125492022-11-252665.51
T3Wendys365482022-12-20226.54
T4Chick-fil-a456242023-01-0442.36
T5In-N-Out458722024-06-0689

36.48

 

I will be running this workflow on January 1st 2023, 2024, 2025,... so ideally what this filter would do is filter out rows T4 and T5 because they come after December 31st 2022 and when I run it next time on January 1st 2024 it would only filter out T5 because it comes after December 31st 2023.

3 REPLIES 3
IraWatt
17 - Castor
17 - Castor

Hey @Travis_Ratliff,

Here is one way to do this using the datetime functions in a filter tool:

IraWatt_0-1663182267867.png

Essentially I use the datetimenow function to get the current date and from that I get the current year. Then I just create a date from that set at the end of December this year and filter from that.

 

If your interested in learning more about the datetime functions there is a great cheat sheet Blog here: https://community.alteryx.com/t5/Engine-Works/DateTime-Functions-Cheat-Sheet/ba-p/844353

 

Any questions or issues please ask

Ira Watt
Technical Consultant
Watt@Bulien.com 

 

Travis_Ratliff
8 - Asteroid

So, if I ran this on January 1st 2023 it would filter for the dates after "2023-12-31" because that is the current year. But I would want it to filter for dates after "2022-12-31". So that is what I am trying to do is figure out how to filter it for the previous year. I hope that makes sense.

IraWatt
17 - Castor
17 - Castor

ahhh okay that straight forward enough. I added a datetimeadd function which minuses 1 year off the current date then sets it to December 31st of that year:

IraWatt_0-1663182848758.png

 

Labels
Top Solution Authors