Skip to main content

Limiting the issues gotten by time


Hi. I’m writing a python script to go into the database and retrieve data matching specified times that things have happened. So for example, event_a happened July 15, 16, 18, 21, 22 and 23 at 1500 each day. I was wondering if there was a way, using the python api, to have it only search as far back as, say, July 19th. One week ago. I know that the get_all, search, and get_iter functions all take a max_records argument, but that isn’t what I was looking for. I’m not saying only look for the first 100 matches. I’m saying only look back in time a week. Does anyone know how I could go about doing that? Thank you in advance.

3 replies

kuovonne
Forum|alt.badge.img+27
  • Brainy
  • 6001 replies
  • July 26, 2021

Welcome to the Airtable community!

You could use filterByFormula in the REST API to get only records that are within the last 7 days. This formula should give you a starting place. You can learn more about the functions in a formula field in the formula field reference.

IF(DATETIME_DIFF(TODAY(),{dateTime field name},"days")<=7,1)

  • Author
  • New Participant
  • 1 reply
  • July 27, 2021
kuovonne wrote:

Welcome to the Airtable community!

You could use filterByFormula in the REST API to get only records that are within the last 7 days. This formula should give you a starting place. You can learn more about the functions in a formula field in the formula field reference.

IF(DATETIME_DIFF(TODAY(),{dateTime field name},"days")<=7,1)

Thank you. I was going to try making a new table that was table_x but only from the past 7 days today and use that instead of the larger table. I’ll try playing around with the formula field a little bit more though using what you suggest.


kuovonne
Forum|alt.badge.img+27
  • Brainy
  • 6001 replies
  • July 27, 2021
Gabriel_Smith wrote:

Thank you. I was going to try making a new table that was table_x but only from the past 7 days today and use that instead of the larger table. I’ll try playing around with the formula field a little bit more though using what you suggest.


You can also create a new view that filters for the records from the past 7 days. Then only get the records from that view.


Reply