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.

Comparing Dates and Keeping the Oldest

ytorjim8
5 - Atom

I have two columns with dates and I want to compare the two and move the oldest date between the 2 to a new column, can someone recommend a solutions for this? Example:

Date 1 Date 2New Date Column
4/14/20254/14/20234/14/2023
4/14/20254/14/20234/14/2023
8/23/20248/23/20228/23/2022
12/20/20236/20/20236/20/2023
6/27/20246/27/20226/27/2022
11/30/202311/15/202111/15/2021
1/18/20251/11/20231/11/2023
1/11/20251/11/20231/11/2023
6/15/20256/15/20236/15/2023
7 REPLIES 7
alexnajm
18 - Pollux
18 - Pollux

Done!

BS_THE_ANALYST
15 - Aurora
15 - Aurora

@ytorjim8 You need to convert your Date columns to the Date datatype. This will allow alteryx to determine which one is 'Older':
1.png

 

Afterwards, we need an if statement!

 

All the best,
BS

LinkedIN

Bulien
JamesCharnley
13 - Pulsar

Hi @ytorjim8 

 

The first thing you'll need to do is convert the string dates to dates, and then just create some formula to check if one date is older than the other, and move it into a new column.

 

image.png

BS_THE_ANALYST
15 - Aurora
15 - Aurora

@JamesCharnley I was conflicted what to do when two dates are on the same day. I see you've decided to have them as null(). Inevitably they will probably want the identical date to be put in that cell 🤔

 

All the best,
BS

LinkedIN

Bulien
JamesCharnley
13 - Pulsar

@BS_THE_ANALYST  a fair point that I hadn't considered but makes sense. You can just edit the else to take either of the dates because that's the only time it's relevant. Nice catch though.

ytorjim8
5 - Atom

Super helpful thank you! If they are the same date I would like just to pull that date in, or if there is a null value in one of the columns I'd want to default to the only value available.

alexnajm
18 - Pollux
18 - Pollux

My original solution accomplishes this!

Labels
Top Solution Authors