Help

Save the date! Join us on October 16 for our Product Ops launch event. Register here.

Compare dates in scripting app

2559 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Pedro_Munoz_Ure
4 - Data Explorer
4 - Data Explorer

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.

2 Replies 2

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.

Thanks a lot, @kuovonne!!