Multiple if's for date calculation


#1

I’m trying to calculate dates based on two values. I have a formula that works for this:

IF({Renewal type} = "Annual", DATETIME_FORMAT(DATEADD({Last register date}, 90, 'days'), "MM/DD/YYYY"))

If I try to add another IF statement then it fails:

IF({Renewal type} = "Annual", DATETIME_FORMAT(DATEADD({Last register date}, 90, 'days'), "MM/DD/YYYY"),IF({Renewal type} = "Semi Annual", DATETIME_FORMAT(DATEADD({Last register date}, 300, 'days'), "MM/DD/YYYY")

What am I doing wrong?


#2

I think you just need to add two more close parentheses “)”. You’ve closed DATETIME_FORMAT function at the end, but but you still need to close the two IF functions.

IF({Renewal type} = "Annual", DATETIME_FORMAT(DATEADD({Last register date}, 90, 'days'), "MM/DD/YYYY"),IF({Renewal type} = "Semi Annual", DATETIME_FORMAT(DATEADD({Last register date}, 300, 'days'), "MM/DD/YYYY")))


#3

Doh! That’s what I get for working on this late at night.

Thanks! That fixed it.


#4

Doesn’t matter: Day, night, afternoon. I’m forever dropping or misplacing parentheses. As a result, to detect or prevent such annoyance, I often create my formulas in Notepad++ and then paste them into Airtable. Notepad++ has automatic highlighting of common delimiters, including parentheses; if you hover over one parenthesis, both it and its complementary match turn red. Makes missing parentheses easy to find. It’s for Windows, but similar apps exist for MacOS and Linux.


#5

Would be really nice to have a decent editor for formulae built into AP. While were at it, a real scripting language…