Sep 23, 2018 07:09 AM
I am trying to add a specific duration to a datetime format, then reformat the output to another datetime.
So for example:
Datetime Field 1 / duration field (h:mm) / Formula Output (datetime format)
I want to take datetime field 1 and add [duration field] to make a datetime format.
Any way to do this?
Sep 24, 2018 04:10 PM
DATEADD({DateTime Field 1}, {Duration Field}, 'seconds')
The Duration field outputs its value as a number in “seconds” to any formula field. You can check this by making a “Duration” field, then making a “Formula” field that just returns the value of the “Duration” field.
If you Duration field had a value of 1:00
(ie, 1 hour), the Formula field would return a value of 3600
, which is the number of seconds in an hour.
Sep 26, 2018 06:30 AM
Ah that explains why when I put minutes it did not work.
Thanks!
Aug 11, 2020 04:53 AM
Can anyone explain what i’m doing wrong? I’m trying to add a duration to a date, but I’m just getting the original date back.
DATEADD({start}, {duration}, ‘seconds’)
with {start} set to “1/1/2000 7:00pm” and {duration} 3:00 (aka 10800 seconds), this formula is returning 1/1/2000 7:00pm, i.e. the exact same start time.
any ideas? thanks!
Aug 11, 2020 07:30 AM
Welcome to the Airtable community!
Could you provide a bit more information?
Aug 11, 2020 11:14 AM
thanks kuovonne for your reply!
the duration field is actually a lookup from another table, and i’ve noticed that if i directly write a number of seconds in the DATEADD, it does work, but the lookup doesn’t. is that not supported?
Aug 11, 2020 11:39 AM
Ah, the duration field actually being a lookup field is the source of your problem. Lookup fields do not play nicely with formulas. A lookup field returns an array, not a simple number.
Here are some workarounds:
MIN
, MAX
, or AVERAGE
). orVALUE({lookup field} & "")
Aug 11, 2020 12:50 PM
i used the second method, and it works! thanks so much
Jan 26, 2022 06:25 AM
Thank you for this Kuovonne