In case you missed the announcement: The Alteryx One Fall Release is here! Learn more about the new features and capabilities here
ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests after December 31, 2025. Set up your security questions now so you can recover your account anytime, just log out and back in to get started. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

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

Get all the records whose date is before the date in the other column

nikhilg19
7 - Meteor

I have 2 columns A & B. want all the records where date in A < date in B.

Been using formula tool,

If [A]<=[B] then "yes" else "No" Endif 

but it differentiates the dates only based on the date number and not the dates based on month and year also.

 

 

 

 

4 REPLIES 4
DavidThorpe
Alteryx Alumni (Retired)

Hi @nikhilg19 

 

You'll need to ensure your fields are of the date type, and use the datetime functions in the formula tool to test this, for example the below:

 

IF DateTimeDiff([Field1],[Field2],'days') <= 0 THEN 'yes' ELSE 'no' ENDIF

 

Tests if field1 (2019-01-20) has a positive/negative variance to field2 (2019-01-30) in number of days. In this case the value returned is a difference of -10 days, hence it returns a 'yes'.

 

I've attached a sample - hope this helps.

 

Thanks 

nikhilg19
7 - Meteor

Hi David,

I dont understand why it is showing as null for the output

Capture.PNGCapture1.PNG

DavidThorpe
Alteryx Alumni (Retired)

Your fields need to be of date type for the formula to work, they need converting to format 2019-01-15 etc.

 

You can do this within the formula, with the following expression:

 

IF DateTimeDiff(
DateTimeParse([Current Due Date],'%d/%m/%y'),
DateTimeParse([Last Friday],'%d/%m/%y')
,'days') <= 0
THEN 'yes'
ELSE 'no'
ENDIF

 

The DateTimeParse converts the dd/mm/yyyy string into a date type of yyyy-mm-dd, which Alteryx needs to form date calculations from

 

Thanks.

DavidThorpe
Alteryx Alumni (Retired)

You can read up more on datetime functions here:

https://help.alteryx.com/2019.1/Reference/Functions.htm#Date/Time

 

Thanks!

Labels
Top Solution Authors