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 Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

General Discussions

Discuss any topics that are not product-specific here.

if statement with datetimeadd invalid type in operator

azagrajoanna
5 - Atom

Hello! I am trying to create this formula:

 

IF [YEAR] = "2019" THEN [DATE] + 365 ELSE [DATE] ENDIF

,

but it gives me malformed if statement or invalid type in operator error. Please help?

1 REPLY 1
jdunkerley79
ACE Emeritus
ACE Emeritus

To add days to a date (or datetime) you need to use the DateTimeAdd function.

 

Additionally if [YEAR] is a number type (not a text field) then you need to not have the quotes as it will complain that types don't match

 

Something like:

 

IF [YEAR] = 2019 THEN DateTimeAdd([DATE], 365, "days") ELSE [DATE] ENDIF

 

should get what you need

Labels
Top Solution Authors