Alteryx Designer Desktop Discussions

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

IF statment not working

Primus
6 - Meteoroid

I have a if formula IF [ID]=[id] THEN [DATE]+1 ELSE "" ENDIF

date is formatted  2020-05-20 00:00:00

what I would want ID=ID then date =2020-05-21 00:00:00

the error message I get is  Formula (25) Parse Error at char(0): Type mismatch in operator +. (Expression #1)

2 REPLIES 2
Kenda
16 - Nebula
16 - Nebula

Hey @Primus 

 

The key here is that in order to add dates, you must use the DateTimeAdd() function!

 

So long as your field is recognized as a date, you should be able to use this expression:

 IF [ID]=[id] THEN DateTimeAdd([DATE],1,"days") ELSE "" ENDIF

 

Hope this helps! 

Hannah_Lissaman
11 - Bolide

Hi @Primus 

 

In Alteryx, you need to use the DateTimeAdd formula to add or subtract from a date - the error you are getting is because you are adding a number to a date, which are different data types in Alteryx.

 

Try DateTimeAdd([DATE], 1, "days")

 

This is a common new thing to get used to for people transitioning from Excel and similar programmes. I would recommend looking through the relevant interactive lesson here: https://community.alteryx.com/t5/Interactive-Lessons/DateTime-Functions/ta-p/98952

 

You can read the documentation on the different DateTime functions here: https://help.alteryx.com/10.1/Reference/DateTimeFunctions.htm

 

Labels