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