Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Nov 12, 2020 12:57 PM
Hi, everyone!
I need your help: I have installed the scripting app, and I am trying to make a report going through all the records in one of my tables.
I would like to be able to compare the date in one of the columns (type Last Modified Time) with the current date (today), because I only want to output records that are 2 days old or less.
I’ve tried some scripts I’ve seen around here (if (DATETIME_DIFF (TODAY (), {theDate}, ‘d’)> 2)), but they don’t work for me.
Thank you.
Nov 12, 2020 01:40 PM
Welcome to the Airtable community!
The code you’ve see (if (DATETIME_DIFF (TODAY (), {theDate}, 'd')> 2)
looks like code for a formula field, not code for Scripting app. Formula fields use an Airtable specific language. Scripting App uses JavaScript.
If you want compare dates in Scripting app, you should convert the date strings from getCellValue
to JavaScript date objects. Then you can use the getTime()
method on the date objects, and finally do the arithmetic with those values.
Nov 12, 2020 11:20 PM
Thanks a lot, @kuovonne!!