How can I filter by date from a collection where the date is part of an addon from Xano

I have an Addon where I’m accessing the ‘last_active’ date property and then filtering if ‘last_active’ is greater than 2 days ago.

I apply the following code to the Collection List

// Access the global variable containing the data
const items = collections['c0876745-e0f1....de439c6947c9']['data']['items'];

// Get the current timestamp
const currentTime = Date.now();

// Calculate the timestamp for 2 days ago
const twoDaysAgo = currentTime - 2 * 24 * 60 * 60 * 1000;

// Filter the items based on the 'last_active' property
const filteredItems = items.filter(item => {
  // Check if 'last_active' property exists and if it's greater than 2 days ago
  return item._content_of_user.last_active && twoDaysAgo > item._content_of_user.last_active;
});

// Return the filtered items
return filteredItems;

The other method is to add the property as an Eval in Xano.

1 Like