Google sheet transformer filter items from the last 30 days

I am trying to figure out how to build a correct transformer to filter out the last 30 days of a list of records.

This is what I have so far. But it is not working. Getting desperate here.

const today = moment();
const someday = moment().subtract(30, "days");
dates = {{query1.data}};

let filtered_data = dates.filter((obj)=>{
  return moment(obj.date).isBetween( someday.format('YYYY-MM-DD'), today.format('YYYY-MM-DD'));

return dates
});

Hey @emieldc! Happy to help here.

Would something like this work for you?

Here's the code I'm using! It's basically the same as yours, just in one line :slight_smile:

{{formatDataAsArray(query1.data).filter(row => row.date > moment('2006-01-01').format('YYYY-MM-DD') && row.date < moment().format('YYYY-MM-DD'))}}

For 1 month specifically, you can use something like:

{{formatDataAsArray(query1.data).filter(row => row.date > moment().subtract(30,'days').format('YYYY-MM-DD') && row.date < moment().format('YYYY-MM-DD'))}}

Let me know how that works for you!