I am trying to filter by date to get one specific record, of which the Name field should = 8/01/2022. (I used the Name field in Airtable to place the dates. I set the field type to date.) The issue I'm having is that although it seems to work fine, it basically ignores the specification for the date and instead returns the first value in the table.
This is what I have for getting the data from airtable.
let isoDate = new Date("08/01/2022").toISOString().slice(0, 10);
const base = new Airtable({ apiKey: apiKey }).base(baseID);
base("tabledata")
.select({
filterByFormula: `"DATESTR({Name})='${isoDate}'"`,
view: "Grid view",
})
.eachPage(
function page(records, fetchNextPage) {
records.forEach(function (record) {
let newEl = {
date: record.get("Name"),
game: record.get("games"),
};
setData(newEl);
});
try {
fetchNextPage();
} catch {
return;
}
},
function done(err) {
if (err) {
console.error(err);
return;
}
}
);
and this is the record that is retrieved:
{date: '2022-07-29', game: Array(6)}
date: "2022-07-29"
game: Array(6)
'2022-07-29' is the name of the first field in my table. when I print the ISOString at any point I get 8/01/2022.