Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Dates Subtraction and conversion

vvissamsetty
8 - Asteroid

I'm trying to subtract a column full of random dates - 12/31/2018. If the result < 366 then pick numbers from 'ST' and if > 366 then pick numbers from 'LT'. It would be great if someone can give me an idea on how to go with this.

6 REPLIES 6
Thableaus
17 - Castor
17 - Castor

Hi @vvissamsetty 

 

In which format are your dates?

 

Cheers,

vvissamsetty
8 - Asteroid

Hi @Thableaus , my dates are in the following format.

Thableaus
17 - Castor
17 - Castor

@vvissamsetty 

 

IF your dates follow the same format as '12/31/2018' then I'd recommend this formula:

 

EDIT: Sorry, typo, change T for Y

 

typo.PNG

 

- Use DateTimeParse function to change your date format to Alteryx format

- Use DateTimeDiff function to calculate difference from dates (in your case, subtract the dates)

 

Something like this:

 

IF DateTimeDiff(DateTimeParse([Date 1], "%m/%d/%Y"), '2018-12-31', "days") < 366 THEN [ST]
ELSE [LT] ENDIF

 

Cheers,

Thableaus
17 - Castor
17 - Castor

@vvissamsetty 

 

It seems they are in this format: 31-Dec-18

 

So, this function would fit:

 

IF DateTimeDiff(DateTimeParse([Date 1], "%d-%b-%y"), '2018-12-31', "days") < 366 THEN [ST]
ELSE [LT] ENDIF

 

Cheers,

Thableaus
17 - Castor
17 - Castor

@vvissamsetty 

 

Also, check this help document to understand how date parsing and specifiers work:

https://help.alteryx.com/10.1/Reference/DateTimeFunctions.htm


Cheers,

vvissamsetty
8 - Asteroid

Thanks @Thableaus !

Labels