Air table node filter formula

Hello,

I would like to get data only for today by using filter. i managed to get today date using “function node” ,
however, i do not know how to enter in the filter using formula to filter “Date(Night)” value.

Any kind assistant is greatly appreciated. :grinning:

@Benjamin123 below is an example workflow to achieve this. The expression inside the “Filter By Formula” parameter would look like:
{Date(Night)} = "{{$json["date"]}}"

Where {{$json["date"]}} is a reference to the data created in Date & Time node (in this case, I’m just referencing the node payload coming into the Airtable node).

Here is Airtable’s official reference for their Formulae: Formula field reference – Airtable Support

{
  "nodes": [
    {
      "parameters": {
        "value": "={{new Date().toISOString()}}",
        "dataPropertyName": "date",
        "toFormat": "YYYY-MM-DD",
        "options": {}
      },
      "name": "Date & Time",
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "operation": "list",
        "application": "appxhaX88hWXJT1GW",
        "table": "Table 8",
        "additionalOptions": {
          "filterByFormula": "={Date(Night)} = \"{{$json[\"date\"]}}\""
        }
      },
      "name": "Airtable",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        650,
        300
      ],
      "credentials": {
        "airtableApi": "cloud demo 2"
      }
    }
  ],
  "connections": {
    "Date & Time": {
      "main": [
        [
          {
            "node": "Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}```

Hello MaxTm

Thank you for your help… however, when i try to use the filter formula, it is not finding anything.

Hey @Benjamin123,

The Date fields in Airtable work a bit differently. I am assuming the Date(Night) field in your Airtable has the type date and not text. If that’s the case, the above formula will not work. You will need a different formula that uses date with it.

I ran a quick test, and if you’re using the Date field, you will have to use the iS_SAME() method. In your example, it should look like IS_SAME({Date(Night)},"{{$json["yesterday"]}}")

I hope this resolves your issue :slight_smile:

Thank you harshil1712,

i wasn’t still able to find the value. is it because my “date(night)” value is inside the “fields” array and i would require it to include “field” in the filter ?

Hey @Benjamin123,

With the expression that I shared, are you still getting 0 items? I tested the formula with static date and it worked well.

hello harshil1712,

yes, i am still getting 0 item.


Hey @Benjamin123,

I created a small workflow to try it out, and I am getting the expected result. Here’s the workflow

{
  "nodes": [
    {
      "parameters": {
        "operation": "list",
        "additionalOptions": {
          "filterByFormula": "=IS_SAME({Date(night)},\"{{$json[\"today\"]}}\")"
        }
      },
      "name": "Airtable",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        840,
        300
      ],
      "credentials": {
        "airtableApi": "Airtable Credentials @n8n"
      }
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "today",
              "value": "={{new Date(Date.now()).toISOString()}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "value": "={{$json[\"today\"]}}",
        "dataPropertyName": "today",
        "toFormat": "YYYY-MM-DD",
        "options": {}
      },
      "name": "Date & Time",
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    }
  ],
  "connections": {
    "Set": {
      "main": [
        [
          {
            "node": "Date & Time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Date & Time": {
      "main": [
        [
          {
            "node": "Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

You can copy and paste the workflow in your n8n instance. You will have to configure your credentials, Base ID, and the Table name.

Hello harshil1712,

it works…thank you very much… :grinning:
but the strange thing is when i copy the same formula back to my existing work flow, it is not working…

i will study all the node in my work flow again to see what went wrong…

maybe there is a bug…i delete my existing airtable node and recreate a new node, it is working well…