Jun 23, 2021 02:56 PM
Hello Everyone,
I’m using a library called “Airtable Python Wrapper” which can be found here: Airtable Python Wrapper Documentation — Airtable Python Wrapper documentation
It has a method, “get_all” that will take an Airtable formula to filter records and return the ones that make it through the formula.
filterByFormula = 'IS_AFTER(LAST_MODIFIED_TIME()+\"2021-01-25T14:23:41.000Z\")'
def get_date_changes():
query = AT.get_all(formula=filterByFormula)
However, that formula returns an empty list. I know that there are records in that table with modification dates later than that as new records are added almost every day. Can anyone tell me what might be wrong with that formula?
Thanks!
-Dan
Jun 26, 2021 11:15 PM
The formula that you’re using isn’t valid for several reasons:
DATETIME_PARSE()
function is required to take a date string and turn it into an actual datetime (the data type used internally by Airtable for date comparisons and calculations)IS_AFTER()
function requires two arguments, but you’re only passing one (the invalid date sum mentioned previously)My gut says that you want to compare the record’s last modified time against that static date in the string. First let’s turn that date string into an actual datetime:
DATETIME_PARSE("2021-01-25T14:23:41.000Z")
In certain situations it’s not necessary to pass a formatting string to the DATETIME_PARSE()
function, and this is one of those. It automatically converts to the correct time.
Next, the correct way to use IS_AFTER()
to compare two dates is by passing each date as a separate argument:
IS_AFTER([date1], [date2])
Inserting the LAST_MODIFIED_TIME()
function and our converted date string into this structure gives us this:
IS_AFTER(LAST_MODIFIED_TIME(), DATETIME_PARSE("2021-01-25T14:23:41.000Z"))
Putting all of that into your Python variable would then look like this:
filterByFormula = 'IS_AFTER(LAST_MODIFIED_TIME(), DATETIME_PARSE("2021-01-25T14:23:41.000Z"))'