Alteryx Designer Desktop Discussions

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

Date Formulas

lindsayhupp
8 - Asteroid

Hello!

 

I have 3 dates: Date1, Date2 and Date3.  All dates are formatted MM/DD/YYYY and I would like to keep them in this presentation. 

 

I am trying to use an if statement to say if Date1 <= Date2, then Date3 - Date1, if not 0.  Can someone please help me put this into the correct formula for Alteryx?  I always have a hard time with formulas involving dates. 

 

Thanks in advance!

4 REPLIES 4
allwynthomas24
11 - Bolide

Hey @lindsayhupp,

 

It would be good if you could provide a sample dataset. 

And to find the difference between two Dates, you can use DateTimeDiff().
Link to all DateTime Functions - https://help.alteryx.com/20221/designer/datetime-functions

Regards.

Luke_C
17 - Castor

Hi @lindsayhupp

 

To use date time functions the data needs to be in yyyy-mm-dd format.

 

For what you're trying to do, something like the below should work (like @allwynthomas24 said sample data is always helpful).

 

IF DateTimeParse([Date1],'%m/%d/%Y') <= DateTimeParse([Date2],'%m/%d/%Y')

THEN DateTimeDiff(DateTimeParse([Date3],'%m/%d/%Y'),DateTimeParse([Date1],'%m/%d/%Y'),'days')

ELSE 0

Endif

Qiu
20 - Arcturus
20 - Arcturus

@lindsayhupp 
When I was about to post, @Luke_C has given the same solution.

But I will just post it any way.
For the date time functions, I always go though the help file, which is really helpful for me.
https://help.alteryx.com/20221/designer/datetime-functions

 

0611-lindsayhupp.PNG

lindsayhupp
8 - Asteroid

I got it to work.  Thank you you so much!

Labels