Hi…I have a field with ‘arrival date’, a field with ‘terms’ (which is days prior to arrival payment is due. This is a number and varies from record to record)(Both are lookup configurations) and I want the third field to calculate the date it would be if the terms number (such as -3) is subtracted from the ‘arrival date’. I tried DATEADD({arrival date},terms,‘days’) but it didn’t work. I experimented with DATEADD({arrival date},-3,‘days’) and with the ‘terms’ look up field just being an integer instead of the look up and those did work so I am not sure how to do this. Thank you!!
Due Date formula
Best answer by Justin_Barrett
Hi Justin…Thank you. It was originally a single select but I changed it to a number thinking that this was the issue as well but through my experimentation, it appears to be a problem with “terms” in my task table being a lookup. It only works if the ‘terms’ in my task table is a # instead of the lookup. I found a workaround that will be fine…I’m becoming a queen of that. I’ll do the dateadd in the groups table instead where the terms is a # and then in the tasks table just make make the due date the lookup. This works just fine, I was trying to not add any more fields to my group table as it is pretty large but I will just hide it. Any other thoughts of why it wouldn’t work if the ‘terms’ field is a lookup?
Thanks,
Sorry. I forgot something tricky about Lookup fields: they return an array when queried by a formula. Even if the associated Link field only points to one other record, the Lookup still returns a single-item array. Some operations in Airtable’s formulas will auto-convert what’s in an array and use it properly, but not all of them, and this is one of those cases.
Here’s what was originally happening. The Single Select field returns a string, even when numbers are used as options, so the Lookup field was returning a single item string array. How DATEADD()
read that string array is unknown, but in a quick test, it appears to treat the array—regardless of its contents—like the number 1, and only adds one day to the specified date. Even if the array contains numbers, those numbers aren’t recognized.
If you want to switch back to that Single Select-driven setup, you can make it work by converting the array in {terms}
to a single string, then converting that string to a number, like this:
DATEADD({arrival date}, VALUE(terms & ""), "days")
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.