Sometimes you need to have content available on the website only for a certain period of time. For example, you publish job offers or internships and there’s a deadline for submitting a CV. Or you want to offer your visitors exclusive educational content for a limited time.
Whatever the case is, there are two ways to manage that kind of content: you can remove it from the Sheet manually after the expiration date or automate this process with the power of Google Sheets!
This blog post will show you how to automatically hide cards on your website after a specific date using =FILTER and =TODAY functions in Google Sheets.
Configuring your content expiration date
Here’s what you need to do:
- Open your Google Sheet and create a Date column, and fill it with dates.
Quick tip: if your content Sheet is connected to a Google Form, by default there will be a column named Timestamp that you can use instead.
2. Make a copy of your data Sheet (duplicate the tab) and remove all the data except the headers row in the duplicated Sheet.
Put this tab to the first place and name it e.g. Filtered listings.
Now it will be your new content source containing only the filtered data.
- Put the FILTER function to the A2 cell:
=FILTER('All listings'!A2:M,'All listings'!A2:A + 7 > TODAY())
7is the number of days after which the row will be considered expired and will be filtered out.
- In your spreadsheet menu go to File -> Settings -> Calculation menu, set Recalculation to On change and every hour and save settings.
As you can see, for now on website there will be only the rows (cards) added in July.
You can change the dates in 'All Listings' Sheet and the number of days in the formula to define the period of time during which the listings will be visible on website.
And, just in case, here you can find our sample Sheet.