We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Expressions in Error Message Tool

kas
8 - Asteroid

Hello,

 

I am trying to use the Error message tool in conjunction with Interface tools to have it return an error message when they select a date outside of a time frame for the Start Date. That time frame is no earlier than the 1st of the year 3 years prior. So currently that would be 1-1-2022, but next year it will be 1-1-2023 and so forth each year, so it can't be a set date. The SQL query is set to restrict the data from not going back further, but they will need to be able to select date ranges within that time frame. I've used this tool before, but with a set date so it was easier.

Screenshots of the Error message tool (current expression works only during 2025), Interface tools, and SQL query portion that restricts data as reference below.

 

 

Error message config.pngInterface tools.pngSQL date portion.png

 

Thank you,

Kim

15 REPLIES 15
alexnajm
18 - Pollux
18 - Pollux

@kas if the limitation is coming in the query and is not getting affected by the user's selection, is the goal just to have your Error Message expression be dynamic to the past three years of dates so they know they won't get older data? i.e. they can't select a start date greater than three years old?

kas
8 - Asteroid

@alexnajm 

 

Yes, so if they select an older date than what the query is pulling, they will receive the error message.

alexnajm
18 - Pollux
18 - Pollux

Cool, then this worked for me: [#1]<DateTimeParse(ToString(DateTimeYear(DateTimeToday())-3)+"-01-01", "%Y-%m-%d")

kas
8 - Asteroid

@alexnajm 

 

Worked like a charm...thank you!!

 

Kim

alexnajm
18 - Pollux
18 - Pollux

Happy to help!

kas
8 - Asteroid

@alexnajm 

 

Hello again!

 

Hope you can help again...I'm looking to have the error pop up when the date is more than 6 months from the current date. (easy for me to adjust the years with your solution, but not sure how to adjust for months)

 

Thank you!

Kim

alexnajm
18 - Pollux
18 - Pollux

Look at using similar logic but using a DateTimeAdd function to add 6 months from the current date!

kas
8 - Asteroid

@alexnajm 

 

I had tried something like that, but I am uncertain of how to write it correctly, I get syntax errors.

alexnajm
18 - Pollux
18 - Pollux

What have you tried? Should just be [#1]>DateTimeAdd(DateTimeToday(),6,'months')

Labels
Top Solution Authors